1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:17:36 +00:00

Pong: Only paint areas that needs to be updated

This commit is contained in:
Karol Kosek 2021-07-11 12:36:47 +02:00 committed by Andreas Kling
parent 9ab528ff5c
commit a90c484d4b
2 changed files with 40 additions and 10 deletions

View file

@ -90,6 +90,14 @@ private:
return { (game_width / 2) - score_width - score_margin, score_margin, score_width, font().glyph_height() };
}
Gfx::IntRect cursor_paddle_target_rect() const
{
int radius = 3;
int center_x = m_player1_paddle.rect.center().x();
int center_y = *m_cursor_paddle_target_y + m_player1_paddle.rect.height() / 2;
return { center_x - radius, center_y - radius, 2 * radius, 2 * radius };
}
Net m_net;
Ball m_ball;
Paddle m_player1_paddle;