diff --git a/Userland/Games/Pong/Game.cpp b/Userland/Games/Pong/Game.cpp index d020a16c37..e421f53ff9 100644 --- a/Userland/Games/Pong/Game.cpp +++ b/Userland/Games/Pong/Game.cpp @@ -36,6 +36,10 @@ void Game::reset_paddles() void Game::reset() { + // Make sure the current ball disappears. + update(enclosing_int_rect(m_ball.rect())); + + reset_scores(); reset_ball(1); reset_paddles(); } @@ -130,6 +134,16 @@ void Game::track_mouse_move(Gfx::IntPoint const& point) update(cursor_paddle_target_rect()); } +void Game::reset_scores() +{ + // Clearing the scores first would lead to overly narrow rects for multi-digit scores. + update(player_1_score_rect()); + update(player_2_score_rect()); + + m_player_1_score = 0; + m_player_2_score = 0; +} + void Game::reset_ball(int serve_to_player) { int position_y_min = (game_width / 2) - 50; diff --git a/Userland/Games/Pong/Game.h b/Userland/Games/Pong/Game.h index ebde760724..801b7f5665 100644 --- a/Userland/Games/Pong/Game.h +++ b/Userland/Games/Pong/Game.h @@ -39,6 +39,7 @@ private: virtual void timer_event(Core::TimerEvent&) override; virtual void track_mouse_move(Gfx::IntPoint const&) override; + void reset_scores(); void reset_ball(int serve_to_player); void reset_paddles(); void tick();