#include "TestStage.h" #include #include #include #include "ExampleGenerator.h" #include "FallingAndOscillating.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)); } } void TestStage::update(const float dt) { m_player.update(dt); for (auto& enemy : m_enemies) enemy.update(dt); m_const.update(dt); bool collided = m_player.collide(m_const.m_bullets); (void) collided; } void TestStage::draw() { m_const.draw(); for (auto& enemy : m_enemies) enemy.draw(); m_player.draw(); } int TestStage::total_bullets() const { return m_const.m_bullets.size(); }