Get the state of the keyboard and check for the status of the keys that you want.
Get the state of the keyboard and check for the status of the keys that you want. Events are not the best way to go in gaming. You need faster response.
DllImport("user32. Dll") public static extern int GetKeyboardState(byte lpKeyState); ... byte bCharData = new byte256; GetKeyboardState(bCharData); Another way, taken from here, DllImport("user32. Dll") static extern short GetKeyState(VirtualKeyStates nVirtKey); ... public static bool IsKeyPressed(VirtualKeyStates testKey) { bool keyPressed = false; short result= GetKeyState(testKey); switch (result) { case 0: // Not pressed and not toggled on.
KeyPressed = false; break; case 1: // Not pressed, but toggled on keyPressed = false; break; default: // Pressed (and may be toggled on) keyPressed = true; break; } return keyPressed; } More links. Basically, these are already available on net. Try searching before asking.It will be faster :).
1 This is correct, events are too slow for games, if you take care of the keystate in your "game loop" it will be both faster and much more responsive – masenkablast Apr 21 '10 at 19:57.
Let's assume you have a "game loop" that updates the object you're moving with the keyboard. The KeyDown event should change the object state to "moving upwards". And your loop then gives it new positions each time it runs.
The KeyUp event should change the state back to "idle". Iff the state is still "moving upwards". You now no longer depend on a keystroke repeating to keep the object moving.
And will have no trouble with the player pressing multiple keys at the same time.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.