D
dupe you
Guest
I have this so far in the step event.
How come the else { speed = 0 } doesn't need to be placed after every keyboard_check for the instance to stop moving & why does it only work when placed after the first if statement?
It works how I wanted it to, yet I'm failing to understand the logic.
if (keyboard_check(vk_left))
{
move_towards_point(x-1,y,4)
}
else { speed = 0 }
if (keyboard_check(vk_right))
{
move_towards_point(x+1,y,4)
}
if (keyboard_check(vk_up))
{
move_towards_point(x,y-1,4)
}
if (keyboard_check(vk_down))
{
move_towards_point(x,y+1,4)
}
How come the else { speed = 0 } doesn't need to be placed after every keyboard_check for the instance to stop moving & why does it only work when placed after the first if statement?
It works how I wanted it to, yet I'm failing to understand the logic.
if (keyboard_check(vk_left))
{
move_towards_point(x-1,y,4)
}
else { speed = 0 }
if (keyboard_check(vk_right))
{
move_towards_point(x+1,y,4)
}
if (keyboard_check(vk_up))
{
move_towards_point(x,y-1,4)
}
if (keyboard_check(vk_down))
{
move_towards_point(x,y+1,4)
}