Page 1 of 1

Complicated movement with arrow keys

PostPosted: Fri Jan 28, 2011 7:34 am
by schnellboot
Hey guys,
I want my player actor move only in 4 directions.
When I hold one key like the up key, player should move up.
But when I press another key (while I hold the up key), for example the left key, player should stop moving up and move left.
When I release left key player should move up again.
And I need this with every key with every key.
Ah and if 3 or 4 keys are pressed player should do nothing.
Thanks !

Re: Complicated movement with arrow keys

PostPosted: Fri Jan 28, 2011 8:50 am
by skydereign
Like this? I made this for someone else a while back, though I added the don't move if three keys are pressed. It uses an array to hold the key order, and two functions to handle the key presses. The actual move code is in draw.

Re: Complicated movement with arrow keys

PostPosted: Fri Jan 28, 2011 12:38 pm
by schnellboot
Wow amazing!
Thanks +1