From bbec07ab3de333649d14a64fa01f7e8ad6d56c58 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 18 Apr 2022 20:14:53 +0200 Subject: Added naive enemy This reminds me ECS a bit too much but I don't think I want to implement one right now... --- ExampleGenerator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ExampleGenerator.cpp') diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp index f7af287..4c86d94 100644 --- a/ExampleGenerator.cpp +++ b/ExampleGenerator.cpp @@ -17,7 +17,6 @@ ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) : m_speed {100}, m_shift {10}, m_segments {2}, - m_origin {400, 20}, m_color {240, 0, 0, 255} { } @@ -28,6 +27,7 @@ ExampleGenerator::update(const float dt) { m_delay += dt; if (m_delay > m_interval) { + const auto pos = position(); m_delay -= m_interval; for (float i = 0; i <= m_segments; ++i) { const float angle = (m_angle - m_cone / 2 + m_cone * i / m_segments) * M_PI; @@ -38,8 +38,8 @@ ExampleGenerator::update(const float dt) bullet.radius = 4; bullet.velocity.x = cos * m_speed; bullet.velocity.y = sin * m_speed; - bullet.position.x = m_origin.x + cos * m_shift; - bullet.position.y = m_origin.y + sin * m_shift; + bullet.position.x = pos.x + cos * m_shift; + bullet.position.y = pos.y + sin * m_shift; m_bullets.push_back(std::move(bullet)); } m_angle += dt * 1.1f; -- cgit v1.1