• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Cancel Diagonal Movement.

D

derp556

Guest
Hi! Just wondering if I could cancel diagonal movement for animation purposes through this code:
(obj_player, step1)
///Movement
if keyboard_check(ord("S"))
{
down = 1
y += 4
}
else
{
down = 0
}

if keyboard_check(ord("W"))
{
up = 1
y += -4
}
else
{
up = 0
}

if keyboard_check(ord("A"))
{
left = 1
x += -4
}
else
{
left = 0
}

if keyboard_check(ord("D"))
{
right = 1
x += 4
}
else
{
right = 0
}
 

Bearman_18

Fruit Stand Deadbeat
That could work, however, I would put your keyboard checks into variables and subtract the left variable from right and up from down and put those in two other variables. then multiply those variables by speed and add them to x and y, respectively. this will make collisions infinitley easier.
 

Bearman_18

Fruit Stand Deadbeat
as far as canceling animation, though, you already use the first four necessary variables, so I would just set the keyboard_check code to them first, and use the method I put above. The codes good though, and just as valid. it should work. just using the method I described might kill several birds with one stone.
 
Top