From 5f0c15b2d3299ea210a78d54e9b10c3cb4266139 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 19 Apr 2022 23:48:20 +0200 Subject: Created factory to handle enemy creation --- EnemyFactory.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 EnemyFactory.cpp (limited to 'EnemyFactory.cpp') 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 + +#include + +#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{x, y}); + auto generator = std::make_unique(bullets); + auto behaviour = std::make_unique(); + 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; +} -- cgit v1.1