diff options
author | Aki <please@ignore.pl> | 2022-04-18 20:14:53 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-18 20:15:05 +0200 |
commit | bbec07ab3de333649d14a64fa01f7e8ad6d56c58 (patch) | |
tree | 06a4cb6e677388da4865075229e4db4090418b83 /ExampleGenerator.cpp | |
parent | a5f91f4d56106112565239c283441432c443c4d2 (diff) | |
download | bullethell2022-bbec07ab3de333649d14a64fa01f7e8ad6d56c58.zip bullethell2022-bbec07ab3de333649d14a64fa01f7e8ad6d56c58.tar.gz bullethell2022-bbec07ab3de333649d14a64fa01f7e8ad6d56c58.tar.bz2 |
Added naive enemy
This reminds me ECS a bit too much but I don't think I want to
implement one right now...
Diffstat (limited to 'ExampleGenerator.cpp')
-rw-r--r-- | ExampleGenerator.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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; |