Complicated movement with arrow keys

Non-platform specific questions.

Complicated movement with arrow keys

Postby schnellboot » Fri Jan 28, 2011 7:34 am

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 !
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Complicated movement with arrow keys

Postby skydereign » Fri Jan 28, 2011 8:50 am

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.
Attachments
move.zip
(72.33 KiB) Downloaded 98 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Complicated movement with arrow keys

Postby schnellboot » Fri Jan 28, 2011 12:38 pm

Wow amazing!
Thanks +1
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest