summaryrefslogtreecommitdiff
path: root/Games/Snake/SnakeGame.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-10 10:57:59 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-10 10:59:04 +0200
commit116cf92156090bb3f5c15d5be145f1283884d65d (patch)
tree4496ab3e8c90add1c40da2eceee71324369ec0c6 /Games/Snake/SnakeGame.cpp
parent656b01eb0fb659fb2d3ee4e6e4413a82543414e3 (diff)
downloadserenity-116cf92156090bb3f5c15d5be145f1283884d65d.zip
LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
Diffstat (limited to 'Games/Snake/SnakeGame.cpp')
-rw-r--r--Games/Snake/SnakeGame.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Games/Snake/SnakeGame.cpp b/Games/Snake/SnakeGame.cpp
index 58ca54c708..3d2bf109e1 100644
--- a/Games/Snake/SnakeGame.cpp
+++ b/Games/Snake/SnakeGame.cpp
@@ -92,13 +92,13 @@ void SnakeGame::spawn_fruit()
m_fruit_type = rand() % m_fruit_bitmaps.size();
}
-Gfx::Rect SnakeGame::score_rect() const
+Gfx::IntRect SnakeGame::score_rect() const
{
int score_width = font().width(m_score_text);
return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() };
}
-Gfx::Rect SnakeGame::high_score_rect() const
+Gfx::IntRect SnakeGame::high_score_rect() const
{
int high_score_width = font().width(m_high_score_text);
return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() };
@@ -197,10 +197,10 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event)
}
}
-Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const
+Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const
{
auto game_rect = rect();
- auto cell_size = Gfx::Size(game_rect.width() / m_columns, game_rect.height() / m_rows);
+ auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows);
return {
coord.column * cell_size.width(),
coord.row * cell_size.height(),
@@ -220,10 +220,10 @@ void SnakeGame::paint_event(GUI::PaintEvent& event)
auto rect = cell_rect(part);
painter.fill_rect(rect, Color::from_rgb(0xaaaa00));
- Gfx::Rect left_side(rect.x(), rect.y(), 2, rect.height());
- Gfx::Rect top_side(rect.x(), rect.y(), rect.width(), 2);
- Gfx::Rect right_side(rect.right() - 1, rect.y(), 2, rect.height());
- Gfx::Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
+ Gfx::IntRect left_side(rect.x(), rect.y(), 2, rect.height());
+ Gfx::IntRect top_side(rect.x(), rect.y(), rect.width(), 2);
+ Gfx::IntRect right_side(rect.right() - 1, rect.y(), 2, rect.height());
+ Gfx::IntRect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
painter.fill_rect(left_side, Color::from_rgb(0xcccc00));
painter.fill_rect(right_side, Color::from_rgb(0x888800));
painter.fill_rect(top_side, Color::from_rgb(0xcccc00));