From 9dc6e5dcc108cd887891756a54748aab62f19626 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 18 Apr 2022 22:27:08 +0200 Subject: Fiddled with enemy building and test generator --- ExampleGenerator.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'ExampleGenerator.cpp') diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp index 76c4cb7..dc9a6b9 100644 --- a/ExampleGenerator.cpp +++ b/ExampleGenerator.cpp @@ -11,12 +11,13 @@ ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) : m_bullets {bullets}, m_delay {0}, - m_interval {0.05f}, + m_interval {0.08f}, m_cone {0.4f}, - m_angle {0.3f}, - m_speed {70}, + m_angle {0.5f}, + m_direction {-1.f}, + m_speed {80}, m_shift {10}, - m_segments {3}, + m_segments {6}, m_color {240, 0, 0, 255} { } @@ -29,26 +30,23 @@ ExampleGenerator::update(const float 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) { const float angle = (m_angle - m_cone / 2 + m_cone * i / m_segments) * M_PI; const float cos = std::cos(angle); const float sin = std::sin(angle); ConstantVelocityBullet bullet; bullet.color = m_color; - bullet.radius = 4; + 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; m_bullets.push_back(std::move(bullet)); + m_color.g += 20; } } - m_angle += dt * 0.5f; - if (m_angle >= 0.7f) { - m_angle -= 0.4f; - if (m_color.g == 0) - m_color.g = 120; - else - m_color.g = 0; - } + m_angle += dt * 0.3f * m_direction; + if (m_angle > 2.f) + m_angle -= 2.f; } -- cgit v1.1