summaryrefslogtreecommitdiffhomepage
path: root/EnemyFactory.cpp
diff options
context:
space:
mode:
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;
+}