summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-18 14:57:56 +0200
committerAki <please@ignore.pl>2022-04-18 14:57:56 +0200
commita5f91f4d56106112565239c283441432c443c4d2 (patch)
treeaad5b8e8d605fe9efa2b1a5b332b14c046e77e30
parent753a37ca74217e10463db49dc1adf65e4e181622 (diff)
downloadbullethell2022-a5f91f4d56106112565239c283441432c443c4d2.zip
bullethell2022-a5f91f4d56106112565239c283441432c443c4d2.tar.gz
bullethell2022-a5f91f4d56106112565239c283441432c443c4d2.tar.bz2
Played a bit with example generator
-rw-r--r--ExampleGenerator.cpp25
-rw-r--r--ExampleGenerator.h2
2 files changed, 18 insertions, 9 deletions
diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp
index 3e1598b..f7af287 100644
--- a/ExampleGenerator.cpp
+++ b/ExampleGenerator.cpp
@@ -11,12 +11,14 @@
ExampleGenerator::ExampleGenerator(ConstantVelocityBullet::Vector& bullets) :
m_bullets {bullets},
m_delay {0},
- m_interval {0.2f},
+ m_interval {0.04f},
m_cone {0.3f},
- m_speed {120},
+ m_angle {0.3f},
+ m_speed {100},
m_shift {10},
- m_segments {3},
- m_origin {400, 20}
+ m_segments {2},
+ m_origin {400, 20},
+ m_color {240, 0, 0, 255}
{
}
@@ -28,11 +30,11 @@ ExampleGenerator::update(const float dt)
if (m_delay > m_interval) {
m_delay -= m_interval;
for (float i = 0; i <= m_segments; ++i) {
- const float angle = ((1 - m_cone) / 2 + m_cone * i / m_segments) * M_PI;
+ 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 = RED;
+ bullet.color = m_color;
bullet.radius = 4;
bullet.velocity.x = cos * m_speed;
bullet.velocity.y = sin * m_speed;
@@ -40,8 +42,13 @@ ExampleGenerator::update(const float dt)
bullet.position.y = m_origin.y + sin * m_shift;
m_bullets.push_back(std::move(bullet));
}
- m_segments += 3;
- if (m_segments > 20)
- m_segments = 3;
+ m_angle += dt * 1.1f;
+ if (m_angle >= 0.7f) {
+ m_angle -= 0.4f;
+ if (m_color.g == 0)
+ m_color.g = 150;
+ else
+ m_color.g = 0;
+ }
}
}
diff --git a/ExampleGenerator.h b/ExampleGenerator.h
index 16c9fc2..4bf0030 100644
--- a/ExampleGenerator.h
+++ b/ExampleGenerator.h
@@ -14,8 +14,10 @@ struct ExampleGenerator : public Generator
float m_delay;
float m_interval;
float m_cone;
+ float m_angle;
int m_speed;
int m_shift;
int m_segments;
Vector2 m_origin;
+ Color m_color;
};