C
chrispytoes
Guest
I just started a brand new project, and this movement code is super simple and I have used it for many games in the past. I just started using GM again after some years but in my mind I don't think there's anything wrong with this code.
The up and down directions work fine, but the player is ALWAYS moving to the right. When I press the 'D' key the player just moves twice as fast to the right, and pressing 'A' makes it stop.
[Create]
speed = 5;
[Step]
if (keyboard_check(ord('W'))) {
y -= speed;
image_angle = 90;
}
if (keyboard_check(ord('A'))) {
x -= speed;
image_angle = 180;
}
if (keyboard_check(ord('S'))) {
y += speed;
image_angle = 270;
}
if (keyboard_check(ord('D'))) {
x += speed;
image_angle = 0;
}
There is no other code or objects in the game yet, this is everything. I'm super confused, there is no other place where the 'x' value is being added onto.
The up and down directions work fine, but the player is ALWAYS moving to the right. When I press the 'D' key the player just moves twice as fast to the right, and pressing 'A' makes it stop.
[Create]
speed = 5;
[Step]
if (keyboard_check(ord('W'))) {
y -= speed;
image_angle = 90;
}
if (keyboard_check(ord('A'))) {
x -= speed;
image_angle = 180;
}
if (keyboard_check(ord('S'))) {
y += speed;
image_angle = 270;
}
if (keyboard_check(ord('D'))) {
x += speed;
image_angle = 0;
}
There is no other code or objects in the game yet, this is everything. I'm super confused, there is no other place where the 'x' value is being added onto.