I am programming a simple Ping-Pong game in C++ but I don't know how to handle key presses. At first I intended to use WM_KEYDOWN, but I don't know how to track two pressed keys at once since the window processing function always gets only one wParam right? Basicaly I have two paddles on each side of the screen and when user presses W/S, left paddle moves, when Up/Down keys are pressed, right paddle moves. However when I press two keys at once only one paddle moves.
Another problem is that there is always a short pause after key is pressed - the paddle moves once in desired direction, then pauses and then continues to move. I have no idea why this happens. On the other hand when I use GetAsyncKeyState() like this:
if (GetAsyncKeyState('S') & 0x8000)
{
PingPong.MoveLeftPaddleDown(hWnd);
}
everything works as intended - both paddles can move at the same time and there is no short pause on the beginning of movement. On the internet I read everywhere that I should use WM_KEYDOWN insead of GetAsyncKeyState() but how to configure it properly? Thank you
MoveLeftPaddleDown
perform the movement or just set a flag that is then checked in your update code? \$\endgroup\$