summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-25 01:49:48 +0200
committerAki <please@ignore.pl>2022-04-25 01:49:48 +0200
commitc1c7fb82aed0c403865896a941388a9e2cc486d0 (patch)
tree7407e44a90d394bd285d5a02841188ed219a3267
parent63c64254a80564e11987ba4af289cf8d47774668 (diff)
downloadbullethell2022-c1c7fb82aed0c403865896a941388a9e2cc486d0.zip
bullethell2022-c1c7fb82aed0c403865896a941388a9e2cc486d0.tar.gz
bullethell2022-c1c7fb82aed0c403865896a941388a9e2cc486d0.tar.bz2
Extended test staged with new enemies
-rw-r--r--ArcGenerator.cpp (renamed from WaveGenerator.cpp)21
-rw-r--r--ArcGenerator.h (renamed from ExampleGenerator.h)10
-rw-r--r--CMakeLists.txt3
-rw-r--r--EnemyFactory.cpp64
-rw-r--r--EnemyFactory.h5
-rw-r--r--ExampleGenerator.cpp55
-rw-r--r--Falling.h1
-rw-r--r--TestStage.cpp24
-rw-r--r--WaveGenerator.h26
9 files changed, 99 insertions, 110 deletions
diff --git a/WaveGenerator.cpp b/ArcGenerator.cpp
index 5d8dd9f..0f442b5 100644
--- a/WaveGenerator.cpp
+++ b/ArcGenerator.cpp
@@ -1,4 +1,4 @@
-#include "WaveGenerator.h"
+#include "ArcGenerator.h"
#include <cmath>
#include <memory>
@@ -9,12 +9,17 @@
#include "ConstantVelocity.h"
-WaveGenerator::WaveGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets) :
+ArcGenerator::ArcGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets) :
m_position {position},
m_bullets {bullets},
m_delay {0},
m_interval {0.22f},
- m_speed {100},
+ m_arc {2.f},
+ m_angle {0},
+ m_rotation {0},
+ m_radius {3},
+ m_last {false},
+ m_speed {80},
m_shift {10},
m_segments {30},
m_color {100, 100, 240, 255}
@@ -23,20 +28,22 @@ WaveGenerator::WaveGenerator(std::shared_ptr<Vector2> position, ConstantVelocity
void
-WaveGenerator::update(const float dt)
+ArcGenerator::update(const float dt)
{
if (!m_enabled)
return;
m_delay += dt;
+ m_angle += m_rotation * dt;
+ const int segments = m_last ? m_segments + 1 : m_segments;
if (m_delay > m_interval) {
m_delay -= m_interval;
- for (float i = 0; i < m_segments; ++i) {
- const float angle = (2.f / m_segments * i) * M_PI;
+ for (float i = 0; i < segments; ++i) {
+ const float angle = (m_angle - m_arc / 2 + m_arc * 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 = 3;
+ bullet.radius = m_radius;
bullet.velocity.x = cos * m_speed;
bullet.velocity.y = sin * m_speed;
bullet.position.x = m_position->x + cos * m_shift;
diff --git a/ExampleGenerator.h b/ArcGenerator.h
index 6db4151..ae02040 100644
--- a/ExampleGenerator.h
+++ b/ArcGenerator.h
@@ -8,20 +8,22 @@
#include "Generator.h"
-class ExampleGenerator : public Generator
+class ArcGenerator : public Generator
{
public:
friend class EnemyFactory;
- ExampleGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets);
+ ArcGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets);
void update(float dt) override;
private:
std::shared_ptr<Vector2> m_position;
ConstantVelocityBullet::Vector& m_bullets;
float m_delay;
float m_interval;
- float m_cone;
+ float m_arc;
float m_angle;
- float m_direction;
+ float m_rotation;
+ float m_radius;
+ bool m_last;
int m_speed;
int m_shift;
int m_segments;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3e9cea..c3e431d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,10 +17,10 @@ endif()
find_package(raylib 3 REQUIRED)
add_executable(
${PROJECT_NAME}
+ ArcGenerator.cpp
ConstantVelocity.cpp
Enemy.cpp
EnemyFactory.cpp
- ExampleGenerator.cpp
Falling.cpp
FallingAndOscillating.cpp
Game.cpp
@@ -34,7 +34,6 @@ add_executable(
Stats.cpp
TestStage.cpp
TitleScreen.cpp
- WaveGenerator.cpp
)
target_link_libraries(${PROJECT_NAME} raylib)
if(MSVC)
diff --git a/EnemyFactory.cpp b/EnemyFactory.cpp
index a154ae5..fc94cd5 100644
--- a/EnemyFactory.cpp
+++ b/EnemyFactory.cpp
@@ -4,28 +4,35 @@
#include <raylib.h>
+#include "ArcGenerator.h"
#include "ConstantVelocity.h"
#include "Enemy.h"
-#include "ExampleGenerator.h"
#include "FallingAndOscillating.h"
-#include "WaveGenerator.h"
Enemy
-EnemyFactory::make_example(
+EnemyFactory::make_small(
ConstantVelocityBullet::Vector& bullets,
const float x, const float y,
const float hold,
const bool mirror)
{
auto position = std::make_shared<Vector2>(Vector2{x, y});
- auto generator = std::make_shared<ExampleGenerator>(position, bullets);
+ auto generator = std::make_shared<ArcGenerator>(position, bullets);
auto behaviour = std::make_shared<FallingAndOscillating>(position, generator);
+ generator->m_interval = 1.2f;
+ generator->m_speed = 60;
+ generator->m_segments = 15;
+ generator->m_radius = 5;
if (mirror) {
generator->m_color = Color{100, 0, 255, 255};
- generator->m_direction *= -1;
+ generator->m_rotation = -0.2f;
+ generator->m_angle = 1.f;
behaviour->m_phase = 1.f;
}
+ else {
+ generator->m_rotation = 0.2f;
+ }
Enemy enemy(position, generator, behaviour);
enemy.m_hold = hold;
return enemy;
@@ -33,14 +40,55 @@ EnemyFactory::make_example(
Enemy
-EnemyFactory::make_waver(
+EnemyFactory::make_thick(
ConstantVelocityBullet::Vector& bullets,
const float x, const float y,
- const float hold)
+ const float hold,
+ const float angle)
{
auto position = std::make_shared<Vector2>(Vector2{x, y});
- auto generator = std::make_shared<WaveGenerator>(position, bullets);
+ auto generator = std::make_shared<ArcGenerator>(position, bullets);
auto behaviour = std::make_shared<Falling>(position, generator);
+ generator->m_interval = 2.3f;
+ generator->m_arc = 0.3f;
+ generator->m_angle = 0.5f;
+ generator->m_last = true;
+ generator->m_segments = 25;
+ generator->m_radius = 9;
+ generator->m_color = Color{160, 30, 50, 200};
+ generator->m_angle = angle;
+ behaviour->m_speed = 20;
+ Enemy enemy(position, generator, behaviour);
+ enemy.m_hold = hold;
+ return enemy;
+}
+
+
+Enemy
+EnemyFactory::make_rotator(
+ ConstantVelocityBullet::Vector& bullets,
+ const float x, const float y,
+ const float hold,
+ const bool mirror)
+{
+ auto position = std::make_shared<Vector2>(Vector2{x, y});
+ auto generator = std::make_shared<ArcGenerator>(position, bullets);
+ auto behaviour = std::make_shared<Falling>(position, generator);
+ generator->m_interval = 0.4f;
+ generator->m_speed = 100;
+ generator->m_arc = 0.1f;
+ generator->m_segments = 2;
+ generator->m_last = true;
+ generator->m_radius = 4;
+ if (mirror) {
+ generator->m_color = Color{30, 80, 170, 255};
+ generator->m_rotation = -0.6f;
+ generator->m_angle = 1.f;
+ }
+ else {
+ generator->m_color = Color{30, 170, 80, 255};
+ generator->m_rotation = 0.6f;
+ }
Enemy enemy(position, generator, behaviour);
enemy.m_hold = hold;
return enemy;
diff --git a/EnemyFactory.h b/EnemyFactory.h
index 6134ae9..934b0ea 100644
--- a/EnemyFactory.h
+++ b/EnemyFactory.h
@@ -6,6 +6,7 @@
struct EnemyFactory
{
- static Enemy make_example(ConstantVelocityBullet::Vector& bullets, float x, float y, float hold, bool mirror=false);
- static Enemy make_waver(ConstantVelocityBullet::Vector& bullets, float x, float y, float hold);
+ static Enemy make_small(ConstantVelocityBullet::Vector& bullets, float x, float y, float hold, bool mirror=false);
+ static Enemy make_thick(ConstantVelocityBullet::Vector& bullets, float x, float y, float hold, float angle=0.5f);
+ static Enemy make_rotator(ConstantVelocityBullet::Vector& bullets, float x, float y, float hold, bool mirror=false);
};
diff --git a/ExampleGenerator.cpp b/ExampleGenerator.cpp
deleted file mode 100644
index f405f58..0000000
--- a/ExampleGenerator.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "ExampleGenerator.h"
-
-#include <cmath>
-#include <memory>
-#include <utility>
-
-#include <raylib.h>
-
-#include "ConstantVelocity.h"
-
-
-ExampleGenerator::ExampleGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets) :
- m_position {position},
- m_bullets {bullets},
- m_delay {0},
- m_interval {0.08f},
- m_cone {0.4f},
- m_angle {0.5f},
- m_direction {-1.f},
- m_speed {80},
- m_shift {10},
- m_segments {6},
- m_color {240, 0, 0, 255}
-{
-}
-
-
-void
-ExampleGenerator::update(const float dt)
-{
- if (!m_enabled)
- return;
- m_delay += dt;
- if (m_delay > m_interval) {
- 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 = 3;
- bullet.velocity.x = cos * m_speed;
- bullet.velocity.y = sin * m_speed;
- bullet.position.x = m_position->x + cos * m_shift;
- bullet.position.y = m_position->y + sin * m_shift;
- m_bullets.push_back(std::move(bullet));
- m_color.g += 20;
- }
- }
- m_angle += dt * 0.3f * m_direction;
- if (m_angle > 2.f)
- m_angle -= 2.f;
-}
diff --git a/Falling.h b/Falling.h
index b50228a..fa4f4fc 100644
--- a/Falling.h
+++ b/Falling.h
@@ -11,6 +11,7 @@
class Falling : virtual public Behaviour
{
public:
+ friend class EnemyFactory;
Falling(std::shared_ptr<Vector2> position, std::shared_ptr<Generator> generator);
void update(float dt) override;
private:
diff --git a/TestStage.cpp b/TestStage.cpp
index 4aa1767..e873699 100644
--- a/TestStage.cpp
+++ b/TestStage.cpp
@@ -11,12 +11,24 @@ static constexpr Color DEEPSPACE {3, 5, 22, 255};
TestStage::TestStage() :
m_const {}
{
- m_enemies.reserve(5);
- m_enemies.push_back(EnemyFactory::make_example(m_const.m_bullets, 300, -10, 0));
- m_enemies.push_back(EnemyFactory::make_example(m_const.m_bullets, 500, -10, 0, true));
- m_enemies.push_back(EnemyFactory::make_waver(m_const.m_bullets, 400, -10, 10));
- m_enemies.push_back(EnemyFactory::make_example(m_const.m_bullets, 550, -10, 20));
- m_enemies.push_back(EnemyFactory::make_example(m_const.m_bullets, 250, -10, 20, true));
+ m_enemies.reserve(17);
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 300, -10, 0));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 500, -10, 0, true));
+ m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 400, -10, 10));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 550, -10, 20));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 250, -10, 20, true));
+ m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 200, -20, 26, -0.2));
+ m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 600, -10, 26, 0.7));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 400, -10, 32));
+ m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 260, -10, 44));
+ m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 540, -10, 44, true));
+ m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 300, -10, 49, true));
+ m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 500, -10, 50));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 360, -10, 56));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 440, -10, 56, true));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 365, -10, 62, true));
+ m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 435, -10, 62));
+ m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 400, -10, 66));
}
diff --git a/WaveGenerator.h b/WaveGenerator.h
deleted file mode 100644
index c3d52f5..0000000
--- a/WaveGenerator.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include <memory>
-
-#include <raylib.h>
-
-#include "ConstantVelocity.h"
-#include "Generator.h"
-
-
-class WaveGenerator : public Generator
-{
-public:
- friend class EnemyFactory;
- WaveGenerator(std::shared_ptr<Vector2> position, ConstantVelocityBullet::Vector& bullets);
- void update(float dt) override;
-private:
- std::shared_ptr<Vector2> m_position;
- ConstantVelocityBullet::Vector& m_bullets;
- float m_delay;
- float m_interval;
- int m_speed;
- int m_shift;
- int m_segments;
- Color m_color;
-};