From 2773854a3e749512826fa8b71b77e754be79836f Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 18 Apr 2022 11:05:24 +0200 Subject: Renamed bullets header to simply ConstantVelocity --- Bullets.cpp | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 Bullets.cpp (limited to 'Bullets.cpp') diff --git a/Bullets.cpp b/Bullets.cpp deleted file mode 100644 index 62b6ea3..0000000 --- a/Bullets.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "Bullets.h" - -#include - - -ConstantVelocitySystem::ConstantVelocitySystem() : - ConstantVelocitySystem(10000) -{ -} - - -ConstantVelocitySystem::ConstantVelocitySystem(int reserved) -{ - m_bullets.reserve(reserved); -} - - -void -ConstantVelocitySystem::update(const float dt) -{ - const int max_height = GetScreenHeight() + MARGIN; - const int min_width = 0 - MARGIN; - const int max_width = GetScreenWidth() + MARGIN; - auto it = m_bullets.begin(); - while (it != m_bullets.end()) { - 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) - it = m_bullets.erase(it); - else - ++it; - } -} - - -void -ConstantVelocitySystem::draw() -{ - for (const auto& bullet : m_bullets) - DrawCircle(bullet.position.x, bullet.position.y, bullet.radius, bullet.color); -} -- cgit v1.1