diff options
author | Aki <please@ignore.pl> | 2022-04-25 01:50:08 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-25 01:50:08 +0200 |
commit | e0b0ed37ad0c52dbc9b207bebee66a4e552dca76 (patch) | |
tree | dc7c2dea9e1037937090ba99639b2c0e1248324d /TestStage.cpp | |
parent | c1c7fb82aed0c403865896a941388a9e2cc486d0 (diff) | |
download | bullethell2022-e0b0ed37ad0c52dbc9b207bebee66a4e552dca76.zip bullethell2022-e0b0ed37ad0c52dbc9b207bebee66a4e552dca76.tar.gz bullethell2022-e0b0ed37ad0c52dbc9b207bebee66a4e552dca76.tar.bz2 |
Added simple on-hit effect
Diffstat (limited to 'TestStage.cpp')
-rw-r--r-- | TestStage.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/TestStage.cpp b/TestStage.cpp index e873699..ccc1f35 100644 --- a/TestStage.cpp +++ b/TestStage.cpp @@ -1,11 +1,14 @@ #include "TestStage.h" +#include <cstdint> + #include <raylib.h> #include "EnemyFactory.h" static constexpr Color DEEPSPACE {3, 5, 22, 255}; +static constexpr float FLASH {0.23f}; TestStage::TestStage() : @@ -35,11 +38,14 @@ TestStage::TestStage() : void TestStage::update(const float dt) { + if (m_flash > 0) + m_flash -= 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 (m_stats) { m_stats->total_bullets = m_const.m_bullets.size(); if (collided) m_stats->lifes--; @@ -55,4 +61,6 @@ 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<std::uint8_t>(m_flash / FLASH * 250)}); } |