For some reason, some combinations of keys can't be pressed at the same time. I'm trying to create a simple game, and these are the controls:
LEFT: go left
RIGHT: go right
UP: jump
SPACEBAR: shoot
When pressing UP + LEFT, the character will move left while jumping. When pressing UP + SPACE, the character will jump and shoot at the same time. LEFT + SPACE will move the character left while shooting. However, when I press UP + LEFT + SPACE, the character will only move left while jumping. It doesn't shoot, but instead my computer will beep every second (the sound you get when you press too many keys at the same time). Is there a way too fix this? When I press UP + RIGHT + SPACE, everything works well (the character moves right while jumping and shooting)
I check wether a key is pressed like this:
Code:
// Inside WndProc. keys is a global array (char keys[256])
case WM_KEYDOWN:
keys[wParam] = 1;
return 0;
case WM_KEYUP:
keys[wParam] = 0;
return 0;
Code:
// Inside function that checks keys and acts on them
if(keys[VK_LEFT] == 1) {
// Move left
}
if(keys[VK_RIGHT] == 1) {
// Move right
}
if(keys[VK_UP] == 1) {
// Jump
}
if(keys[VK_SPACE] == 1) {
// Shoot
}