From fd9232b3d3a3aee28a5965a5ebc4077f8db7c652 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 20 Apr 2022 00:28:48 +0200 Subject: Streamlined enemy composition --- ExampleGenerator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ExampleGenerator.cpp') diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp index 5bdade8..f405f58 100644 --- a/ExampleGenerator.cpp +++ b/ExampleGenerator.cpp @@ -1,6 +1,7 @@ #include "ExampleGenerator.h" #include +#include #include #include @@ -8,7 +9,8 @@ #include "ConstantVelocity.h" -ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) : +ExampleGenerator::ExampleGenerator(std::shared_ptr position, ConstantVelocityBullet::Vector& bullets) : + m_position {position}, m_bullets {bullets}, m_delay {0}, m_interval {0.08f}, @@ -30,7 +32,6 @@ ExampleGenerator::update(const float dt) return; m_delay += dt; if (m_delay > m_interval) { - const auto pos = position(); m_delay -= m_interval; m_color.g = 0; for (float i = 0; i <= m_segments; ++i) { @@ -42,8 +43,8 @@ ExampleGenerator::update(const float dt) bullet.radius = 3; bullet.velocity.x = cos * m_speed; bullet.velocity.y = sin * m_speed; - bullet.position.x = pos.x + cos * m_shift; - bullet.position.y = pos.y + sin * m_shift; + bullet.position.x = m_position->x + cos * m_shift; + bullet.position.y = m_position->y + sin * m_shift; m_bullets.push_back(std::move(bullet)); m_color.g += 20; } -- cgit v1.1