Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - marcelo

#1
Programming Help / Implementing WASD Movement
August 27, 2018, 05:03:42 AM
Hi there,

I'm working on simple object that responds to WASD input by moving. The only issue I have is that after a couple seconds of holding down a key, the movement and keystrokes start to lag - I've included a GIF to show what I mean. I've tried both code and blocks, and both of them yield the same output.

Any suggestions would be greatly appreciated, thanks

Creation code:

left_speed = 0
right_speed = 0
up_speed = 0
down_speed = 0


Step code:

if keyboard_check(ord('W')) {
up_speed = 5
}
else {
up_speed = 0
}

if keyboard_check(ord('A')) {
left_speed = 5
}
else {
left_speed = 0
}

if keyboard_check(ord('S')) {
down_speed = 5
}
else {
down_speed = 0
}

if keyboard_check(ord('D')) {
right_speed = 5
}
else {
right_speed = 0
}

x -= left_speed
x += right_speed
y += down_speed
y -= up_speed