Pong: Fix paddle movement across resets if keys are held

The game waited for the next key down event before moving the player
paddle. Now the state of the arrow keys is carried over between resets.
This commit is contained in:
Dmitrii Ubskii 2021-05-16 23:47:10 +03:00 committed by Linus Groh
commit 9a7aac1c6a
Notes: sideshowbarker 2024-07-18 17:49:30 +09:00

View file

@ -23,8 +23,8 @@ void Game::reset_paddles()
{ {
m_cursor_paddle_target_y.clear(); m_cursor_paddle_target_y.clear();
m_player1_paddle.moving_up = false; m_player1_paddle.moving_up = m_up_key_held;
m_player1_paddle.moving_down = false; m_player1_paddle.moving_down = m_down_key_held;
m_player1_paddle.rect = { game_width - 12, game_height / 2 - 40, m_player1_paddle.width, m_player1_paddle.height }; m_player1_paddle.rect = { game_width - 12, game_height / 2 - 40, m_player1_paddle.width, m_player1_paddle.height };
m_player2_paddle.moving_up = false; m_player2_paddle.moving_up = false;