mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
FlappyBug: Add cloud and sky graphics
We now have a nice sunset sky and some random cloud graphics. The obstacles will get graphics at some point too :)
This commit is contained in:
parent
28e08f08c2
commit
ddc855ffcd
6 changed files with 50 additions and 7 deletions
|
@ -56,7 +56,9 @@ void Game::paint_event(GUI::PaintEvent& event)
|
|||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
painter.fill_rect(rect(), m_sky_color);
|
||||
painter.draw_tiled_bitmap(rect(), *m_background_bitmap);
|
||||
|
||||
painter.draw_scaled_bitmap(m_cloud.rect(), *m_cloud.bitmap(), m_cloud.bitmap()->rect(), 0.2f);
|
||||
|
||||
painter.fill_rect(enclosing_int_rect(m_obstacle.top_rect()), m_obstacle.color);
|
||||
painter.fill_rect(enclosing_int_rect(m_obstacle.bottom_rect()), m_obstacle.color);
|
||||
|
@ -98,6 +100,7 @@ void Game::tick()
|
|||
m_bug.fall();
|
||||
m_bug.apply_velocity();
|
||||
m_obstacle.x -= 4 + m_difficulty / 16.0f;
|
||||
m_cloud.x -= m_difficulty / 16.0f;
|
||||
|
||||
if (m_bug.y > game_height || m_bug.y < 0) {
|
||||
game_over();
|
||||
|
@ -110,6 +113,10 @@ void Game::tick()
|
|||
if (m_obstacle.x < 0) {
|
||||
m_obstacle.reset();
|
||||
}
|
||||
|
||||
if (m_cloud.x < 0) {
|
||||
m_cloud.reset();
|
||||
}
|
||||
}
|
||||
|
||||
m_restart_cooldown -= 1.0f / 16.0f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue