#include "TestStage.h" #include #include #include "EnemyFactory.h" #include "Globals.h" #include "OverScreen.h" static constexpr Color DEEPSPACE {3, 5, 22, 255}; TestStage::TestStage() : m_const {} { m_enemies.reserve(17); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 300, -10, 0)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 500, -10, 0, true)); m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 400, -10, 10)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 550, -10, 20)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 250, -10, 20, true)); m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 200, -20, 26, -0.2)); m_enemies.push_back(EnemyFactory::make_thick(m_const.m_bullets, 600, -10, 26, 0.7)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 400, -10, 32)); m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 260, -10, 44)); m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 540, -10, 44, true)); m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 300, -10, 49, true)); m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 500, -10, 50)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 360, -10, 56)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 440, -10, 56, true)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 365, -10, 62, true)); m_enemies.push_back(EnemyFactory::make_small(m_const.m_bullets, 435, -10, 62)); m_enemies.push_back(EnemyFactory::make_rotator(m_const.m_bullets, 400, -10, 66)); } void TestStage::update(const float dt) { m_flash.update(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); if (collided) m_flash.start(); if (m_stats) { m_stats->total_bullets = m_const.m_bullets.size(); if (collided) m_stats->lifes--; } bool all_done = true; for (const auto& enemy : m_enemies) { if (!enemy.gone()) { all_done = false; break; } } if (all_done) g_game.set(std::make_unique(m_stats)); } void TestStage::draw() { ClearBackground(DEEPSPACE); m_const.draw(); for (auto& enemy : m_enemies) enemy.draw(); m_player.draw(); m_flash.draw(); }