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.


Topics - marcelo

Pages: 1
1
Programming Help / Implementing WASD Movement
« on: August 27, 2018, 12: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:
Code: [Select]
left_speed = 0
right_speed = 0
up_speed = 0
down_speed = 0

Step code:
Code: [Select]
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

Pages: 1