summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-18 22:27:08 +0200
committerAki <please@ignore.pl>2022-04-18 22:27:08 +0200
commit9dc6e5dcc108cd887891756a54748aab62f19626 (patch)
tree5285196b76d3cc999b833b77535153b4a25b0271
parent60672810d676498f610657e4c17931d15483b7d4 (diff)
downloadbullethell2022-9dc6e5dcc108cd887891756a54748aab62f19626.zip
bullethell2022-9dc6e5dcc108cd887891756a54748aab62f19626.tar.gz
bullethell2022-9dc6e5dcc108cd887891756a54748aab62f19626.tar.bz2
Fiddled with enemy building and test generator
-rw-r--r--ExampleGenerator.cpp24
-rw-r--r--ExampleGenerator.h1
-rw-r--r--TestStage.cpp9
3 files changed, 18 insertions, 16 deletions
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;
}
diff --git a/ExampleGenerator.h b/ExampleGenerator.h
index c74ccfd..2710d03 100644
--- a/ExampleGenerator.h
+++ b/ExampleGenerator.h
@@ -15,6 +15,7 @@ struct ExampleGenerator : public Generator
float m_interval;
float m_cone;
float m_angle;
+ float m_direction;
int m_speed;
int m_shift;
int m_segments;
diff --git a/TestStage.cpp b/TestStage.cpp
index 653d3c2..2ce4118 100644
--- a/TestStage.cpp
+++ b/TestStage.cpp
@@ -11,9 +11,12 @@ TestStage::TestStage() :
m_const {}
{
m_enemies.reserve(2);
- for (const float x : {200.f, 600.f}) {
- Enemy enemy(std::make_unique<ExampleGenerator>(m_const.m_bullets));
- enemy.set_position(x, 20.f);
+ for (const float x : {300.f, 500.f}) {
+ auto generator = std::make_unique<ExampleGenerator>(m_const.m_bullets);
+ if (x > 400.f)
+ generator->m_direction *= -1;
+ Enemy enemy(std::move(generator));
+ enemy.set_position(x, 100.f);
m_enemies.push_back(std::move(enemy));
}
}