Problem with keyboard Input.
Hi everybody...
happy thanksgiving!
Here is my problem. I am making this classic game, a clone of asteroids you could say. Well you controll an aircraft, view from top and you shoot at enemies that come at you from top of the screen.
If you play the game, then you will recognize that the control doesnt work all the way. Its possible to manuver in all directions( using arrow keys); however if you press the spacebar to shoot the laser, then all directions work except the upper left.
So, pressing space, left, and up at the same time doesnt work. Can anyone help me figure out why?
Code:
void HandleKeys()
{
if (GetKeyState(VK_RIGHT) < 0)
strider.posX = strider.posX + 4;
if (GetKeyState(VK_LEFT) < 0)
strider.posX = strider.posX - 4;
if (GetKeyState(VK_UP) < 0)
strider.posY = strider.posY - 4;
if (GetKeyState(VK_DOWN) < 0)
strider.posY = strider.posY + 4;
}
To better understand, here is the complete source code for .NET c++
thank you!