diff options
author | Aki <please@ignore.pl> | 2022-04-18 22:05:26 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-18 22:05:26 +0200 |
commit | 60672810d676498f610657e4c17931d15483b7d4 (patch) | |
tree | 367cce7e35459198a21895c529e0fd2a08bb7aca /ConstantVelocity.cpp | |
parent | d5c207373aa163a9300909ea0b9f4476749b91ee (diff) | |
download | bullethell2022-60672810d676498f610657e4c17931d15483b7d4.zip bullethell2022-60672810d676498f610657e4c17931d15483b7d4.tar.gz bullethell2022-60672810d676498f610657e4c17931d15483b7d4.tar.bz2 |
Added removal of bullets above the field in ConstantVelocity
Diffstat (limited to 'ConstantVelocity.cpp')
-rw-r--r-- | ConstantVelocity.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ConstantVelocity.cpp b/ConstantVelocity.cpp index efe3117..b7f3b99 100644 --- a/ConstantVelocity.cpp +++ b/ConstantVelocity.cpp @@ -12,6 +12,7 @@ ConstantVelocitySystem::ConstantVelocitySystem() void ConstantVelocitySystem::update(const float dt) { + const int min_height = 0 - 3 * MARGIN; const int max_height = GetScreenHeight() + MARGIN; const int min_width = 0 - MARGIN; const int max_width = GetScreenWidth() + MARGIN; @@ -20,7 +21,9 @@ ConstantVelocitySystem::update(const float dt) auto& bullet = *it; bullet.position.x += bullet.velocity.x * dt; bullet.position.y += bullet.velocity.y * dt; - if (bullet.position.y > max_height || bullet.position.x < min_width || bullet.position.x > max_width) + const bool y_exceeded = bullet.position.y < min_height || bullet.position.y > max_height; + const bool x_exceeded = bullet.position.x < min_width || bullet.position.x > max_width; + if (y_exceeded || x_exceeded) it = m_bullets.erase(it); else ++it; |