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 --- TestStage.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'TestStage.cpp') diff --git a/TestStage.cpp b/TestStage.cpp index e6406f8..d858fcb 100644 --- a/TestStage.cpp +++ b/TestStage.cpp @@ -5,28 +5,19 @@ #include -#include "ExampleGenerator.h" -#include "FallingAndOscillating.h" +#include "EnemyFactory.h" TestStage::TestStage() : m_player {}, m_const {} { - m_enemies.reserve(2); - for (const float x : {350.f, 450.f, 400.f}) { - auto position = std::make_shared(Vector2{x, 100.f}); - auto generator = std::make_unique(m_const.m_bullets); - auto behaviour = std::make_unique(); - if (x > 410.f) { - generator->m_direction *= -1; - behaviour->set_phase(1.f); - } - Enemy enemy(position, std::move(generator), std::move(behaviour)); - if (x > 390.f && x < 410.f) - enemy.set_hold(20.f); - m_enemies.push_back(std::move(enemy)); - } + m_enemies.reserve(5); + m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 300, -10, 0))); + m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 500, -10, 0, true))); + m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 400, -10, 10))); + m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 550, -10, 20))); + m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 250, -10, 20, true))); } -- cgit v1.1