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
character move diagonally
Make a bool array for storing whether a key is currently held down.
When a key is pressed set the array entry to true, and when a key is released set it to false.
You must then move your character around elsewhere in your code.
Code: Select all
bool keys[KEY_KEY_CODES_COUNT];
Code: Select all
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;