woods
Member
being very new to coding i find it difficult to wrap my head around where in this nest of lf statements can i put this bit.. i know i have the right parts.. just not sure where to put them...
im trying to wrap my head around teh whole for/while/with/do/ loop thing
i know this is a basic fundamental tool and everyone should have a firm grip on it... bbut like i said.. im trying to learn how it works ;o)
for(i=0; i<3; i+=1)
=====
flyCounter is a custom alarm set to pick a number to change direction
i have a couple more things to plug in here..
isWalking = true
isCarry = false
isFlying = false
im pretty sure they go in after the movement code, but i want the timer to run 2 or 3 times before changing the state.. im just at a loss as to where they all go...
i know the first thing everybody is going to say is statemachine...... but honestly if im having problems with a basic if statement... im not ready to add more to my plate until i get a better handle on what i got in front of me.
Code:
// isFlying code
if (isFlying = true)
{
{
flyCounter = flyCounter + 1
if flyCounter = 60
{
var fnumber=irandom(3) //pick random direction: 0=south, 1=north, 2= west, 3=east,
{
if (fnumber == 0)
{
motion_set(0,2.5); image_speed=0.2; sprite_index=spr_chicken_flying_right; // fly right
}
if (fnumber == 1)
{
motion_set(270,2.5); image_speed=0.2; sprite_index=spr_chicken_flying_down; // fly down
}
if (fnumber == 2)
{
motion_set(180,2.5); image_speed=0.2; sprite_index=spr_chicken_flying_left; // fly left
}
if (fnumber == 3)
{
motion_set(90,2.5); image_speed=0.2; sprite_index=spr_chicken_flying_up; // fly up
}
}
flyCounter = 0; //reset move counter
move_snap(32,32);
}
}
}
i know this is a basic fundamental tool and everyone should have a firm grip on it... bbut like i said.. im trying to learn how it works ;o)
for(i=0; i<3; i+=1)
=====
flyCounter is a custom alarm set to pick a number to change direction
i have a couple more things to plug in here..
isWalking = true
isCarry = false
isFlying = false
im pretty sure they go in after the movement code, but i want the timer to run 2 or 3 times before changing the state.. im just at a loss as to where they all go...
i know the first thing everybody is going to say is statemachine...... but honestly if im having problems with a basic if statement... im not ready to add more to my plate until i get a better handle on what i got in front of me.