mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
Pong: Fix score display
Player 1's score used to be score's width offset to the right. Now it's score_margin away from the divider line, same as player 2's. Also factored out score margin and increased it from 2px to 5px just to make it look a little nicer.
This commit is contained in:
parent
d897abf4c2
commit
7c67c9b45f
1 changed files with 4 additions and 2 deletions
|
@ -75,16 +75,18 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
constexpr static int score_margin = 5;
|
||||
|
||||
Gfx::IntRect player_1_score_rect() const
|
||||
{
|
||||
int score_width = font().width(String::formatted("{}", m_player_1_score));
|
||||
return { (game_width / 2) + score_width + 2, 2, score_width, font().glyph_height() };
|
||||
return { (game_width / 2) + score_margin, score_margin, score_width, font().glyph_height() };
|
||||
}
|
||||
|
||||
Gfx::IntRect player_2_score_rect() const
|
||||
{
|
||||
int score_width = font().width(String::formatted("{}", m_player_2_score));
|
||||
return { (game_width / 2) - score_width - 2, 2, score_width, font().glyph_height() };
|
||||
return { (game_width / 2) - score_width - score_margin, score_margin, score_width, font().glyph_height() };
|
||||
}
|
||||
|
||||
Net m_net;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue