summaryrefslogtreecommitdiffhomepage
path: root/EnemyFactory.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-19 23:48:20 +0200
committerAki <please@ignore.pl>2022-04-19 23:48:20 +0200
commit5f0c15b2d3299ea210a78d54e9b10c3cb4266139 (patch)
tree137190dde6dcab1951301f1a2ac1db8481878f5a /EnemyFactory.cpp
parent78097b5496209b56cef9d7fc8d6c13e4c87e0eb1 (diff)
downloadbullethell2022-5f0c15b2d3299ea210a78d54e9b10c3cb4266139.zip
bullethell2022-5f0c15b2d3299ea210a78d54e9b10c3cb4266139.tar.gz
bullethell2022-5f0c15b2d3299ea210a78d54e9b10c3cb4266139.tar.bz2
Created factory to handle enemy creation
Diffstat (limited to 'EnemyFactory.cpp')
-rw-r--r--EnemyFactory.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/EnemyFactory.cpp b/EnemyFactory.cpp
new file mode 100644
index 0000000..b573228
--- /dev/null
+++ b/EnemyFactory.cpp
@@ -0,0 +1,30 @@
+#include "EnemyFactory.h"
+
+#include <memory>
+
+#include <raylib.h>
+
+#include "ConstantVelocity.h"
+#include "Enemy.h"
+#include "ExampleGenerator.h"
+#include "FallingAndOscillating.h"
+
+
+Enemy
+EnemyFactory::make_example(
+ 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_unique<ExampleGenerator>(bullets);
+ auto behaviour = std::make_unique<FallingAndOscillating>();
+ if (mirror) {
+ generator->m_direction *= -1;
+ behaviour->set_phase(1.f);
+ }
+ Enemy enemy(position, std::move(generator), std::move(behaviour));
+ enemy.m_hold = hold;
+ return enemy;
+}