From e51044a8872a05313fa92cad15eedf1f93f26aee Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 25 Apr 2022 02:02:11 +0200 Subject: Moved flash to own class and used it as transition to death screen --- TestStage.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'TestStage.cpp') diff --git a/TestStage.cpp b/TestStage.cpp index ccc1f35..b851b0b 100644 --- a/TestStage.cpp +++ b/TestStage.cpp @@ -8,7 +8,6 @@ static constexpr Color DEEPSPACE {3, 5, 22, 255}; -static constexpr float FLASH {0.23f}; TestStage::TestStage() : @@ -38,14 +37,13 @@ TestStage::TestStage() : void TestStage::update(const float dt) { - if (m_flash > 0) - m_flash -= dt; + m_flash.update(dt); m_player.update(dt); for (auto& enemy : m_enemies) enemy.update(dt); m_const.update(dt); bool collided = m_player.collide(m_const.m_bullets); - if (collided) m_flash = FLASH; + if (collided) m_flash.start(); if (m_stats) { m_stats->total_bullets = m_const.m_bullets.size(); if (collided) m_stats->lifes--; @@ -61,6 +59,5 @@ TestStage::draw() for (auto& enemy : m_enemies) enemy.draw(); m_player.draw(); - if (m_flash > 0) - DrawRectangle(0, 0, 800, 600, Color{250, 190, 130, static_cast(m_flash / FLASH * 250)}); + m_flash.draw(); } -- cgit v1.1