S
Stac
Guest
Hi there.
My GMS version is 1.4 and I have a problem with next code:
The problem is that image_angle doesn't works, when I'm pressing "down and left" or "down and right".
And if I'm using next code(with "else"):
image_angle this time doesn't working, when I'm pressing "up and right" or "right and down".
I'm trying to fix it second day, but I'm newbie in GML so it's hard. Can you give me right working code or just advice how do it right (how bad my code)?
P.S. Sorry for mistakes in the text if they has. I'm came here, cuz don't have GM community in my country.
Thanks in advance.
GIF of second code working:
My GMS version is 1.4 and I have a problem with next code:
Code:
key_right = keyboard_check(ord('D'));
key_left = -keyboard_check(ord('A'));
key_up = -keyboard_check(ord('W'));
key_down = keyboard_check(ord('S'));
hmove = key_left + key_right;
vmove = key_up + key_down;
hsp = hmove * movespeed;
vsp = vmove * movespeed;
x+=hsp;
y+=vsp;
if (key_left) image_angle = 180;
if (key_left == -1 && key_up == -1) image_angle = 135;
if (key_left == -1 && key_down == 1) image_angle = 225;
if (key_right) image_angle = 0;
if (key_right == 1 && key_up == -1) image_angle = 45;
if (key_right == 1 && key_down == 1) image_angle = 315;
if (key_up) image_angle = 90;
if (key_down) image_angle = 270;
And if I'm using next code(with "else"):
Code:
///Get the player's input
key_right = keyboard_check(ord('D'));
key_left = -keyboard_check(ord('A'));
key_up = -keyboard_check(ord('W'));
key_down = keyboard_check(ord('S'));
//React to inputs
hmove = key_left + key_right;
vmove = key_up + key_down;
hsp = hmove * movespeed;
vsp = vmove * movespeed;
x+=hsp;
y+=vsp;
if (key_left) image_angle = 180;
else if (key_left == -1 && key_up == -1) image_angle = 135;
else if (key_left == -1 && key_down == 1) image_angle = 225;
else if (key_right) image_angle = 0;
else if (key_right == 1 && key_up == -1) image_angle = 45;
else if (key_right == 1 && key_down == 1) image_angle = 315;
else if (key_up) image_angle = 90;
else if (key_down) image_angle = 270;
I'm trying to fix it second day, but I'm newbie in GML so it's hard. Can you give me right working code or just advice how do it right (
P.S. Sorry for mistakes in the text if they has. I'm came here, cuz don't have GM community in my country.
Thanks in advance.
GIF of second code working: