character move diagonally

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
happyer
Posts: 17
Joined: Wed Aug 15, 2007 2:07 pm

character move diagonally

Post by happyer »

My program will use WASD to control the movement of a character. It can go forward, backward, left and right. But I don't know how to write the code for the character to move diagonally. Since when I press a button, then another button, the first button memory will be gone. So what should I do? I am using the method of IEventReceiver and use switch to check which button I pressed. Is it possible or should I use SKeyMap? But seems that SKeyMap don't have self-define action, right?

Thanks for helping
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Make a bool array for storing whether a key is currently held down.

Code: Select all

bool keys[KEY_KEY_CODES_COUNT];
When a key is pressed set the array entry to true, and when a key is released set it to false.

Code: Select all

keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
You must then move your character around elsewhere in your code.
Post Reply