Au, a dormir que tinc son

This commit is contained in:
2024-11-06 22:22:35 +01:00
parent d902bb9088
commit 0e527ff9d9
8 changed files with 422 additions and 628 deletions

View File

@@ -3,15 +3,6 @@
#include "param.h" // para param
#include "utils.h" // para ParamGame, Param, Zone, BLOCK
// Constructor
BalloonFormations::BalloonFormations()
{
initBalloonFormations();
initBalloonFormationPools();
initGameStages();
}
// Inicializa las formaciones enemigas
void BalloonFormations::initBalloonFormations()
{
constexpr int y4 = -BLOCK;
@@ -31,682 +22,437 @@ void BalloonFormations::initBalloonFormations()
const int x1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2);
const int x1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0];
// Inicializa a cero las variables
for (int j = 0; j < NUMBER_OF_BALLOON_FORMATIONS; ++j)
{
balloon_formation_[j].number_of_balloons = 0;
for (int i = 0; i < MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION; ++i)
{
balloon_formation_[j].init[i] = BalloonFormationParams();
}
}
balloon_formation_.reserve(NUMBER_OF_BALLOON_FORMATIONS);
constexpr int CREATION_TIME = 300;
int inc_x = 0;
int inc_time = 0;
int j = 0;
// #00 - Dos enemigos BALLOON4 uno a cada extremo
j = 0;
balloon_formation_[j].number_of_balloons = 2;
inc_x = x4_100;
inc_time = 0;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x4_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
std::vector<BalloonFormationParams> init_params = {
BalloonFormationParams(x4_0, y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
BalloonFormationParams(x4_100, y4, -BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
balloon_formation_.emplace_back(2, init_params);
}
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
j = 1;
balloon_formation_[j].number_of_balloons = 2;
inc_x = param.game.play_area.center_x;
inc_time = 0;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2) + (i * inc_x);
balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
std::vector<BalloonFormationParams> init_params = {
BalloonFormationParams(param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME),
BalloonFormationParams(param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2), y4, -BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)};
balloon_formation_.emplace_back(2, init_params);
}
// #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
j = 2;
balloon_formation_[j].number_of_balloons = 4;
inc_x = BALLOON_SIZE[1] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #02 - Cuatro enemigos BALLOON2 uno detrás del otro. A la izquierda y hacia el centro
{
balloon_formation_[j].init[i].x = x2_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 4; ++i)
{
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(4, init_params);
}
// #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
j = 3;
balloon_formation_[j].number_of_balloons = 4;
inc_x = BALLOON_SIZE[1] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #03 - Cuatro enemigos BALLOON2 uno detrás del otro. A la derecha y hacia el centro
{
balloon_formation_[j].init[i].x = x2_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 4; ++i)
{
init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(4, init_params);
}
// #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha
j = 4;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[2] * 2;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda
j = 5;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[2] * 2;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha
j = 6;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[2] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda
j = 7;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[2] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha
j = 8;
balloon_formation_[j].number_of_balloons = 6;
inc_x = BALLOON_SIZE[0] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x1_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 6; ++i)
{
init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(6, init_params);
}
// #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda
j = 9;
balloon_formation_[j].number_of_balloons = 6;
inc_x = BALLOON_SIZE[0] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x1_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 6; ++i)
{
init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(6, init_params);
}
// #10 - Tres enemigos BALLOON4 seguidos desde la izquierda
j = 10;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[3] + 1;
inc_time = 15;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x4_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #11 - Tres enemigos BALLOON4 seguidos desde la derecha
j = 11;
balloon_formation_[j].number_of_balloons = 3;
inc_x = BALLOON_SIZE[3] + 1;
inc_time = 15;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x4_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 3; ++i)
{
init_params.emplace_back(x4_100 - (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i));
}
balloon_formation_.emplace_back(3, init_params);
}
// #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
j = 12;
balloon_formation_[j].number_of_balloons = 6;
inc_x = BALLOON_SIZE[1] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #12 - Seis enemigos BALLOON2 uno detrás del otro. A la izquierda y hacia el centro
{
balloon_formation_[j].init[i].x = x2_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 6; ++i)
{
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(6, init_params);
}
// #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
j = 13;
balloon_formation_[j].number_of_balloons = 6;
inc_x = BALLOON_SIZE[1] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #13 - Seis enemigos BALLOON2 uno detrás del otro. A la derecha y hacia el centro
{
balloon_formation_[j].init[i].x = x2_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 6; ++i)
{
init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(6, init_params);
}
// #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados
j = 14;
balloon_formation_[j].number_of_balloons = 5;
inc_x = BALLOON_SIZE[2] * 2;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 5; ++i)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(5, init_params);
}
// #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados
j = 15;
balloon_formation_[j].number_of_balloons = 5;
inc_x = BALLOON_SIZE[2] * 2;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 5; ++i)
{
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(5, init_params);
}
// #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos
j = 16;
balloon_formation_[j].number_of_balloons = 5;
inc_x = BALLOON_SIZE[2] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 5; ++i)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(5, init_params);
}
// #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos
j = 17;
balloon_formation_[j].number_of_balloons = 5;
inc_x = BALLOON_SIZE[2] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 5; ++i)
{
init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(5, init_params);
}
// #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos
j = 18;
balloon_formation_[j].number_of_balloons = 12;
inc_x = BALLOON_SIZE[0] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x1_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 12; ++i)
{
init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(12, init_params);
}
// #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos
j = 19;
balloon_formation_[j].number_of_balloons = 12;
inc_x = BALLOON_SIZE[0] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
{
balloon_formation_[j].init[i].x = x1_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < 12; ++i)
{
init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i));
}
balloon_formation_.emplace_back(12, init_params);
}
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos
j = 20;
balloon_formation_[j].number_of_balloons = 4;
inc_x = BALLOON_SIZE[3] + 1;
inc_time = 0;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 4 / 2;
for (int i = 0; i < 4; ++i)
{
balloon_formation_[j].init[i].x = x4_0 + (i * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
if (i < half)
{
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
}
else
{
init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
}
}
else
{
balloon_formation_[j].init[i].x = x4_100 - ((i - half) * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
}
balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
balloon_formation_.emplace_back(4, init_params);
}
// #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos
j = 21;
balloon_formation_[j].number_of_balloons = 10;
inc_x = BALLOON_SIZE[1] + 1;
inc_time = 3;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 4 / 2;
for (int i = 0; i < 4; ++i)
{
balloon_formation_[j].init[i].x = x2_0 + (i * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
if (i < half)
{
init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
}
else
{
init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i));
}
}
else
{
balloon_formation_[j].init[i].x = x2_100 - ((i - half) * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half));
}
balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_.emplace_back(4, init_params);
}
// #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simetricos
j = 22;
balloon_formation_[j].number_of_balloons = 10;
inc_x = BALLOON_SIZE[2] * 2;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #21 - Diez enemigos BALLOON2 uno detrás del otro. Izquierda/derecha. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 10 / 2;
for (int i = 0; i < 10; ++i)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
if (i < half)
{
init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * i));
}
else
{
init_params.emplace_back(x2_100 - ((i - half) * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * (i - half)));
}
}
else
{
balloon_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half));
}
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_.emplace_back(10, init_params);
}
// #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simetricos
j = 23;
balloon_formation_[j].number_of_balloons = 10;
inc_x = BALLOON_SIZE[2] + 1;
inc_time = 10;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 10 / 2;
for (int i = 0; i < 10; ++i)
{
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
if (i < half)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
else
{
init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half)));
}
}
else
{
balloon_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x);
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half));
}
balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_.emplace_back(10, init_params);
}
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos
j = 24;
balloon_formation_[j].number_of_balloons = 30;
inc_time = 5;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 10 / 2;
for (int i = 0; i < 10; ++i)
{
balloon_formation_[j].init[i].x = x1_50;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * i);
if (i < half)
{
init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i));
}
else
{
init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half)));
}
}
else
{
balloon_formation_[j].init[i].x = x1_50;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * (i - half));
}
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_.emplace_back(10, init_params);
}
// #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simetricos
j = 25;
balloon_formation_[j].number_of_balloons = 30;
inc_time = 5;
for (int i = 0; i < balloon_formation_[j].number_of_balloons; i++)
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simétricos
{
const int half = balloon_formation_[j].number_of_balloons / 2;
if (i < half)
std::vector<BalloonFormationParams> init_params;
const int half = 30 / 2;
for (int i = 0; i < 30; ++i)
{
balloon_formation_[j].init[i].x = x1_50 + 20;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
if (i < half)
{
init_params.emplace_back(x1_50, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * i));
}
else
{
init_params.emplace_back(x1_50, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * (i - half)));
}
}
else
{
balloon_formation_[j].init[i].x = x1_50 - 20;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half));
}
balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_.emplace_back(30, init_params);
}
// Crea las mismas formaciones pero con hexagonos a partir de la posición 50 del vector
for (int k = 0; k < j + 1; k++)
// #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simétricos
{
balloon_formation_[k + 50].number_of_balloons = balloon_formation_[k].number_of_balloons;
for (int i = 0; i < balloon_formation_[k + 50].number_of_balloons; i++)
std::vector<BalloonFormationParams> init_params;
const int half = 30 / 2;
for (int i = 0; i < 30; ++i)
{
balloon_formation_[k + 50].init[i].x = balloon_formation_[k].init[i].x;
balloon_formation_[k + 50].init[i].y = balloon_formation_[k].init[i].y;
balloon_formation_[k + 50].init[i].vel_x = balloon_formation_[k].init[i].vel_x;
balloon_formation_[k + 50].init[i].creation_counter = balloon_formation_[k].init[i].creation_counter;
balloon_formation_[k + 50].init[i].size = balloon_formation_[k].init[i].size;
balloon_formation_[k + 50].init[i].type = BalloonType::FLOATER;
if (i < half)
{
init_params.emplace_back(x1_50 + 20, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * i));
}
else
{
init_params.emplace_back(x1_50 - 20, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * (i - half)));
}
}
balloon_formation_.emplace_back(30, init_params);
}
// Reservar espacio para el vector
balloon_formation_.resize(100);
// Crea las mismas formaciones pero con hexágonos a partir de la posición 50 del vector
for (int k = 0; k < 50; k++)
{
std::vector<BalloonFormationParams> init_params;
for (int i = 0; i < balloon_formation_.at(k).number_of_balloons; i++)
{
init_params.emplace_back(
balloon_formation_.at(k).init.at(i).x,
balloon_formation_.at(k).init.at(i).y,
balloon_formation_.at(k).init.at(i).vel_x,
BalloonType::FLOATER,
balloon_formation_.at(k).init.at(i).size,
balloon_formation_.at(k).init.at(i).creation_counter);
}
balloon_formation_.at(k + 50) = BalloonFormationUnit(balloon_formation_.at(k).number_of_balloons, init_params);
}
// TEST
balloon_formation_[99].number_of_balloons = 4;
std::vector<BalloonFormationParams> test_params = {
{10, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE1, 200},
{50, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE2, 200},
{90, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200},
{140, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}};
balloon_formation_[99].init[0].x = 10;
balloon_formation_[99].init[0].y = y1;
balloon_formation_[99].init[0].vel_x = 0;
balloon_formation_[99].init[0].size = BalloonSize::SIZE1;
balloon_formation_[99].init[0].creation_counter = 200;
balloon_formation_[99].init[1].x = 50;
balloon_formation_[99].init[1].y = y1;
balloon_formation_[99].init[1].vel_x = 0;
balloon_formation_[99].init[1].size = BalloonSize::SIZE2;
balloon_formation_[99].init[1].creation_counter = 200;
balloon_formation_[99].init[2].x = 90;
balloon_formation_[99].init[2].y = y1;
balloon_formation_[99].init[2].vel_x = 0;
balloon_formation_[99].init[2].size = BalloonSize::SIZE3;
balloon_formation_[99].init[2].creation_counter = 200;
balloon_formation_[99].init[3].x = 140;
balloon_formation_[99].init[3].y = y1;
balloon_formation_[99].init[3].vel_x = 0;
balloon_formation_[99].init[3].size = BalloonSize::SIZE4;
balloon_formation_[99].init[3].creation_counter = 200;
balloon_formation_.at(99) = BalloonFormationUnit(4, test_params);
}
// Inicializa los conjuntos de formaciones
void BalloonFormations::initBalloonFormationPools()
{
// EnemyPool #0
balloon_formation_pool_[0].set[0] = balloon_formation_[0];
balloon_formation_pool_[0].set[1] = balloon_formation_[1];
balloon_formation_pool_[0].set[2] = balloon_formation_[2];
balloon_formation_pool_[0].set[3] = balloon_formation_[3];
balloon_formation_pool_[0].set[4] = balloon_formation_[4];
balloon_formation_pool_[0].set[5] = balloon_formation_[5];
balloon_formation_pool_[0].set[6] = balloon_formation_[6];
balloon_formation_pool_[0].set[7] = balloon_formation_[7];
balloon_formation_pool_[0].set[8] = balloon_formation_[8];
balloon_formation_pool_[0].set[9] = balloon_formation_[9];
// Reserva espacio para cada pool de formaciones
balloon_formation_pool_.resize(NUMBER_OF_SETS_PER_POOL);
// EnemyPool #1
balloon_formation_pool_[1].set[0] = balloon_formation_[10];
balloon_formation_pool_[1].set[1] = balloon_formation_[11];
balloon_formation_pool_[1].set[2] = balloon_formation_[12];
balloon_formation_pool_[1].set[3] = balloon_formation_[13];
balloon_formation_pool_[1].set[4] = balloon_formation_[14];
balloon_formation_pool_[1].set[5] = balloon_formation_[15];
balloon_formation_pool_[1].set[6] = balloon_formation_[16];
balloon_formation_pool_[1].set[7] = balloon_formation_[17];
balloon_formation_pool_[1].set[8] = balloon_formation_[18];
balloon_formation_pool_[1].set[9] = balloon_formation_[19];
// Set #0
balloon_formation_pool_.at(0) = {
&balloon_formation_.at(0), &balloon_formation_.at(1), &balloon_formation_.at(2),
&balloon_formation_.at(3), &balloon_formation_.at(4), &balloon_formation_.at(5),
&balloon_formation_.at(6), &balloon_formation_.at(7), &balloon_formation_.at(8),
&balloon_formation_.at(9)};
// EnemyPool #2
balloon_formation_pool_[2].set[0] = balloon_formation_[0];
balloon_formation_pool_[2].set[1] = balloon_formation_[1];
balloon_formation_pool_[2].set[2] = balloon_formation_[2];
balloon_formation_pool_[2].set[3] = balloon_formation_[3];
balloon_formation_pool_[2].set[4] = balloon_formation_[4];
balloon_formation_pool_[2].set[5] = balloon_formation_[55];
balloon_formation_pool_[2].set[6] = balloon_formation_[56];
balloon_formation_pool_[2].set[7] = balloon_formation_[57];
balloon_formation_pool_[2].set[8] = balloon_formation_[58];
balloon_formation_pool_[2].set[9] = balloon_formation_[59];
// Set #1
balloon_formation_pool_.at(1) = {
&balloon_formation_.at(10), &balloon_formation_.at(11), &balloon_formation_.at(12),
&balloon_formation_.at(13), &balloon_formation_.at(14), &balloon_formation_.at(15),
&balloon_formation_.at(16), &balloon_formation_.at(17), &balloon_formation_.at(18),
&balloon_formation_.at(19)};
// EnemyPool #3
balloon_formation_pool_[3].set[0] = balloon_formation_[50];
balloon_formation_pool_[3].set[1] = balloon_formation_[51];
balloon_formation_pool_[3].set[2] = balloon_formation_[52];
balloon_formation_pool_[3].set[3] = balloon_formation_[53];
balloon_formation_pool_[3].set[4] = balloon_formation_[54];
balloon_formation_pool_[3].set[5] = balloon_formation_[5];
balloon_formation_pool_[3].set[6] = balloon_formation_[6];
balloon_formation_pool_[3].set[7] = balloon_formation_[7];
balloon_formation_pool_[3].set[8] = balloon_formation_[8];
balloon_formation_pool_[3].set[9] = balloon_formation_[9];
// Set #2
balloon_formation_pool_.at(2) = {
&balloon_formation_.at(0), &balloon_formation_.at(1), &balloon_formation_.at(2),
&balloon_formation_.at(3), &balloon_formation_.at(4), &balloon_formation_.at(55),
&balloon_formation_.at(56), &balloon_formation_.at(57), &balloon_formation_.at(58),
&balloon_formation_.at(59)};
// EnemyPool #4
balloon_formation_pool_[4].set[0] = balloon_formation_[60];
balloon_formation_pool_[4].set[1] = balloon_formation_[61];
balloon_formation_pool_[4].set[2] = balloon_formation_[62];
balloon_formation_pool_[4].set[3] = balloon_formation_[63];
balloon_formation_pool_[4].set[4] = balloon_formation_[64];
balloon_formation_pool_[4].set[5] = balloon_formation_[65];
balloon_formation_pool_[4].set[6] = balloon_formation_[66];
balloon_formation_pool_[4].set[7] = balloon_formation_[67];
balloon_formation_pool_[4].set[8] = balloon_formation_[68];
balloon_formation_pool_[4].set[9] = balloon_formation_[69];
// Set #3
balloon_formation_pool_.at(3) = {
&balloon_formation_.at(50), &balloon_formation_.at(51), &balloon_formation_.at(52),
&balloon_formation_.at(53), &balloon_formation_.at(54), &balloon_formation_.at(5),
&balloon_formation_.at(6), &balloon_formation_.at(7), &balloon_formation_.at(8),
&balloon_formation_.at(9)};
// EnemyPool #5
balloon_formation_pool_[5].set[0] = balloon_formation_[10];
balloon_formation_pool_[5].set[1] = balloon_formation_[61];
balloon_formation_pool_[5].set[2] = balloon_formation_[12];
balloon_formation_pool_[5].set[3] = balloon_formation_[63];
balloon_formation_pool_[5].set[4] = balloon_formation_[14];
balloon_formation_pool_[5].set[5] = balloon_formation_[65];
balloon_formation_pool_[5].set[6] = balloon_formation_[16];
balloon_formation_pool_[5].set[7] = balloon_formation_[67];
balloon_formation_pool_[5].set[8] = balloon_formation_[18];
balloon_formation_pool_[5].set[9] = balloon_formation_[69];
// Set #4
balloon_formation_pool_.at(4) = {
&balloon_formation_.at(60), &balloon_formation_.at(61), &balloon_formation_.at(62),
&balloon_formation_.at(63), &balloon_formation_.at(64), &balloon_formation_.at(65),
&balloon_formation_.at(66), &balloon_formation_.at(67), &balloon_formation_.at(68),
&balloon_formation_.at(69)};
// EnemyPool #6
balloon_formation_pool_[6].set[0] = balloon_formation_[60];
balloon_formation_pool_[6].set[1] = balloon_formation_[11];
balloon_formation_pool_[6].set[2] = balloon_formation_[62];
balloon_formation_pool_[6].set[3] = balloon_formation_[13];
balloon_formation_pool_[6].set[4] = balloon_formation_[64];
balloon_formation_pool_[6].set[5] = balloon_formation_[15];
balloon_formation_pool_[6].set[6] = balloon_formation_[66];
balloon_formation_pool_[6].set[7] = balloon_formation_[17];
balloon_formation_pool_[6].set[8] = balloon_formation_[68];
balloon_formation_pool_[6].set[9] = balloon_formation_[19];
// Set #5
balloon_formation_pool_.at(5) = {
&balloon_formation_.at(10), &balloon_formation_.at(61), &balloon_formation_.at(12),
&balloon_formation_.at(63), &balloon_formation_.at(14), &balloon_formation_.at(65),
&balloon_formation_.at(16), &balloon_formation_.at(67), &balloon_formation_.at(18),
&balloon_formation_.at(69)};
// EnemyPool #7
balloon_formation_pool_[7].set[0] = balloon_formation_[20];
balloon_formation_pool_[7].set[1] = balloon_formation_[21];
balloon_formation_pool_[7].set[2] = balloon_formation_[22];
balloon_formation_pool_[7].set[3] = balloon_formation_[23];
balloon_formation_pool_[7].set[4] = balloon_formation_[24];
balloon_formation_pool_[7].set[5] = balloon_formation_[65];
balloon_formation_pool_[7].set[6] = balloon_formation_[66];
balloon_formation_pool_[7].set[7] = balloon_formation_[67];
balloon_formation_pool_[7].set[8] = balloon_formation_[68];
balloon_formation_pool_[7].set[9] = balloon_formation_[69];
// Set #6
balloon_formation_pool_.at(6) = {
&balloon_formation_.at(60), &balloon_formation_.at(11), &balloon_formation_.at(62),
&balloon_formation_.at(13), &balloon_formation_.at(64), &balloon_formation_.at(15),
&balloon_formation_.at(66), &balloon_formation_.at(17), &balloon_formation_.at(68),
&balloon_formation_.at(19)};
// EnemyPool #8
balloon_formation_pool_[8].set[0] = balloon_formation_[70];
balloon_formation_pool_[8].set[1] = balloon_formation_[71];
balloon_formation_pool_[8].set[2] = balloon_formation_[72];
balloon_formation_pool_[8].set[3] = balloon_formation_[73];
balloon_formation_pool_[8].set[4] = balloon_formation_[74];
balloon_formation_pool_[8].set[5] = balloon_formation_[15];
balloon_formation_pool_[8].set[6] = balloon_formation_[16];
balloon_formation_pool_[8].set[7] = balloon_formation_[17];
balloon_formation_pool_[8].set[8] = balloon_formation_[18];
balloon_formation_pool_[8].set[9] = balloon_formation_[19];
// Set #7
balloon_formation_pool_.at(7) = {
&balloon_formation_.at(20), &balloon_formation_.at(21), &balloon_formation_.at(22),
&balloon_formation_.at(23), &balloon_formation_.at(24), &balloon_formation_.at(65),
&balloon_formation_.at(66), &balloon_formation_.at(67), &balloon_formation_.at(68),
&balloon_formation_.at(69)};
// EnemyPool #9
balloon_formation_pool_[9].set[0] = balloon_formation_[20];
balloon_formation_pool_[9].set[1] = balloon_formation_[21];
balloon_formation_pool_[9].set[2] = balloon_formation_[22];
balloon_formation_pool_[9].set[3] = balloon_formation_[23];
balloon_formation_pool_[9].set[4] = balloon_formation_[24];
balloon_formation_pool_[9].set[5] = balloon_formation_[70];
balloon_formation_pool_[9].set[6] = balloon_formation_[71];
balloon_formation_pool_[9].set[7] = balloon_formation_[72];
balloon_formation_pool_[9].set[8] = balloon_formation_[73];
balloon_formation_pool_[9].set[9] = balloon_formation_[74];
// Set #8
balloon_formation_pool_.at(8) = {
&balloon_formation_.at(70), &balloon_formation_.at(71), &balloon_formation_.at(72),
&balloon_formation_.at(73), &balloon_formation_.at(74), &balloon_formation_.at(15),
&balloon_formation_.at(16), &balloon_formation_.at(17), &balloon_formation_.at(18),
&balloon_formation_.at(19)};
// Set #9
balloon_formation_pool_.at(9) = {
&balloon_formation_.at(20), &balloon_formation_.at(21), &balloon_formation_.at(22),
&balloon_formation_.at(23), &balloon_formation_.at(24), &balloon_formation_.at(70),
&balloon_formation_.at(71), &balloon_formation_.at(72), &balloon_formation_.at(73),
&balloon_formation_.at(74)};
}
// Inicializa las fases del juego
void BalloonFormations::initGameStages()
{
// STAGE 1
stage_[0].number = 1;
stage_[0].power_to_complete = 200;
stage_[0].min_menace = 7 + (4 * 1);
stage_[0].max_menace = 7 + (4 * 3);
stage_[0].balloon_pool = balloon_formation_pool_[0];
// STAGE 2
stage_[1].number = 2;
stage_[1].power_to_complete = 300;
stage_[1].min_menace = 7 + (4 * 2);
stage_[1].max_menace = 7 + (4 * 4);
stage_[1].balloon_pool = balloon_formation_pool_[1];
// STAGE 3
stage_[2].number = 3;
stage_[2].power_to_complete = 600;
stage_[2].min_menace = 7 + (4 * 3);
stage_[2].max_menace = 7 + (4 * 5);
stage_[2].balloon_pool = balloon_formation_pool_[2];
// STAGE 4
stage_[3].number = 4;
stage_[3].power_to_complete = 600;
stage_[3].min_menace = 7 + (4 * 3);
stage_[3].max_menace = 7 + (4 * 5);
stage_[3].balloon_pool = balloon_formation_pool_[3];
// STAGE 5
stage_[4].number = 5;
stage_[4].power_to_complete = 600;
stage_[4].min_menace = 7 + (4 * 4);
stage_[4].max_menace = 7 + (4 * 6);
stage_[4].balloon_pool = balloon_formation_pool_[4];
// STAGE 6
stage_[5].number = 6;
stage_[5].power_to_complete = 600;
stage_[5].min_menace = 7 + (4 * 4);
stage_[5].max_menace = 7 + (4 * 6);
stage_[5].balloon_pool = balloon_formation_pool_[5];
// STAGE 7
stage_[6].number = 7;
stage_[6].power_to_complete = 650;
stage_[6].min_menace = 7 + (4 * 5);
stage_[6].max_menace = 7 + (4 * 7);
stage_[6].balloon_pool = balloon_formation_pool_[6];
// STAGE 8
stage_[7].number = 8;
stage_[7].power_to_complete = 750;
stage_[7].min_menace = 7 + (4 * 5);
stage_[7].max_menace = 7 + (4 * 7);
stage_[7].balloon_pool = balloon_formation_pool_[7];
// STAGE 9
stage_[8].number = 9;
stage_[8].power_to_complete = 850;
stage_[8].min_menace = 7 + (4 * 6);
stage_[8].max_menace = 7 + (4 * 8);
stage_[8].balloon_pool = balloon_formation_pool_[8];
// STAGE 10
stage_[9].number = 10;
stage_[9].power_to_complete = 950;
stage_[9].min_menace = 7 + (4 * 7);
stage_[9].max_menace = 7 + (4 * 10);
stage_[9].balloon_pool = balloon_formation_pool_[9];
}
// Devuelve una fase
Stage BalloonFormations::getStage(int index) const { return stage_[index]; }

View File

@@ -1,13 +1,13 @@
#pragma once
#include "balloon.h"
#include "balloon.h" // para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include <vector>
constexpr int NUMBER_OF_BALLOON_FORMATIONS = 100;
constexpr int MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION = 50;
constexpr int NUMBER_OF_SETS_PER_POOL = 10;
constexpr int NUMBER_OF_STAGES = 10;
// Estructuras
struct BalloonFormationParams
{
int x = 0; // Posición en el eje X donde crear el globo
@@ -25,34 +25,23 @@ struct BalloonFormationParams
: x(x_val), y(y_val), vel_x(vel_x_val), type(type_val), size(size_val), creation_counter(creation_counter_val) {}
};
struct BalloonFormationUnit // Contiene la información de una formación enemiga
struct BalloonFormationUnit
{
int number_of_balloons; // Cantidad de globos que forman la formación
BalloonFormationParams init[MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION]; // Vector con todas las inicializaciones de los globos de la formación
int number_of_balloons; // Cantidad de globos que forman la formación
std::vector<BalloonFormationParams> init; // Vector con todas las inicializaciones de los globos de la formación
// Constructor
BalloonFormationUnit(int num_balloons, const std::vector<BalloonFormationParams> &init_params)
: number_of_balloons(num_balloons), init(init_params) {}
};
struct BalloonFormationPool
{
BalloonFormationUnit set[NUMBER_OF_SETS_PER_POOL]; // Conjunto de formaciones de globos
};
using BalloonFormationPool = std::vector<const BalloonFormationUnit *>;
struct Stage // Contiene todas las variables relacionadas con una fase
{
BalloonFormationPool balloon_pool; // El conjunto de formaciones de globos de la fase
int power_to_complete; // Cantidad de poder que se necesita para completar la fase
int max_menace; // Umbral máximo de amenaza de la fase
int min_menace; // Umbral mínimo de amenaza de la fase
int number; // Número de fase
};
// Clase BalloonFormations, para gestionar las formaciones de globos
class BalloonFormations
{
private:
// Variables
Stage stage_[NUMBER_OF_STAGES]; // Variable con los datos de cada pantalla
BalloonFormationUnit balloon_formation_[NUMBER_OF_BALLOON_FORMATIONS]; // Vector con todas las formaciones enemigas
BalloonFormationPool balloon_formation_pool_[NUMBER_OF_STAGES]; // Variable con los diferentes conjuntos de formaciones enemigas
std::vector<BalloonFormationUnit> balloon_formation_; // Vector con todas las formaciones enemigas
std::vector<BalloonFormationPool> balloon_formation_pool_; // Variable con los diferentes conjuntos de formaciones enemigas
// Inicializa las formaciones enemigas
void initBalloonFormations();
@@ -60,16 +49,18 @@ private:
// Inicializa los conjuntos de formaciones
void initBalloonFormationPools();
// Inicializa las fases del juego
void initGameStages();
public:
// Constructor
BalloonFormations();
BalloonFormations()
{
initBalloonFormations();
initBalloonFormationPools();
}
// Destructor
~BalloonFormations() = default;
// Devuelve una fase
Stage getStage(int index) const;
};
// Getters
const BalloonFormationPool &getPool(int pool) { return balloon_formation_pool_.at(pool); }
const BalloonFormationUnit &getSet(int pool, int set) { return *balloon_formation_pool_.at(pool).at(set); }
};

View File

@@ -1,4 +1,5 @@
#include "balloon_manager.h"
#include "stage.h"
#include <numeric> // Para accumulate
#include <algorithm> // Para find_if, clamp, min, remove_if
#include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VE...
@@ -12,7 +13,7 @@
// Constructor
BalloonManager::BalloonManager()
: explosions_(std::make_unique<Explosions>()),
balloon_formations_(std::make_unique<BalloonFormations>()) {init();}
balloon_formations_(std::make_unique<BalloonFormations>()) { init(); }
// Inicializa
void BalloonManager::init()
@@ -328,4 +329,25 @@ void BalloonManager::normalColorsToAllBalloons()
{
balloon->useNormalColor();
}
}
// Recarga las texturas
void BalloonManager::reLoad()
{
for (auto &texture : balloon_textures_)
{
texture->reLoad();
}
}
// Crea dos globos gordos
void BalloonManager::createTwoBigBalloons()
{
const auto set = balloon_formations_->getSet(0, 1);
const auto numEnemies = set.number_of_balloons;
for (int i = 0; i < numEnemies; ++i)
{
auto p = set.init[i];
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
}
}

View File

@@ -91,4 +91,10 @@ public:
// Cambia el color de todos los globos
void normalColorsToAllBalloons();
// Recarga las texturas
void reLoad();
// Crea dos globos gordos
void createTwoBigBalloons();
};

View File

@@ -1,7 +1,8 @@
#include "game.h"
#include "asset.h" // Para Asset
#include "background.h" // Para Background
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "stage.h"
#include "asset.h" // Para Asset
#include "background.h" // Para Background
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "balloon_manager.h"
#include "fade.h" // Para Fade, FadeType
#include "global_inputs.h" // Para check
@@ -795,7 +796,7 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
{
// Si no tiene cafes, muere
pauseMusic();
stopAllBalloons();
balloon_manager_->stopAllBalloons();
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
screen_->shake();
JA_PlaySound(Resource::get()->getSound("coffeeout.wav"));
@@ -1112,7 +1113,7 @@ void Game::checkEvents()
{
case SDLK_1: // Crea una powerball
{
createPowerBall();
balloon_manager_->createPowerBall();
break;
}
case SDLK_2: // Crea dos globos gordos
@@ -1166,9 +1167,6 @@ void Game::reloadTextures()
for (auto &texture : item_textures_)
texture->reLoad();
for (auto &texture : balloon_textures_)
texture->reLoad();
for (auto &textures : player_textures_)
for (auto &texture : textures)
texture->reLoad();
@@ -1579,8 +1577,7 @@ void Game::setTotalPower()
total_power_to_complete_game_ = 0;
for (int i = 0; i < 10; ++i)
{
total_power_to_complete_game_ +=
balloon_formations_->getStage(i).power_to_complete;
total_power_to_complete_game_ += Stage::get(i).power_to_complete;
}
}
@@ -1593,7 +1590,9 @@ void Game::initScoreboard()
{
scoreboard_->setName(player->getScoreBoardPanel(), player->getName());
if (player->isWaiting())
{
scoreboard_->setMode(player->getScoreBoardPanel(), ScoreboardMode::WAITING);
}
}
}
@@ -1655,19 +1654,6 @@ void Game::initPlayers(int player_id)
player->setInvulnerable(false);
}
// Crea dos globos gordos
void Game::createTwoBigBalloons()
{
const auto set = balloon_formations_->getStage(0).balloon_pool.set[1];
const auto numEnemies = set.number_of_balloons;
for (int i = 0; i < numEnemies; ++i)
{
auto p = set.init[i];
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_,
p.creation_counter);
}
}
// Pausa la música
void Game::pauseMusic()
{
@@ -1784,28 +1770,28 @@ void Game::cleanVectors()
// Gestiona el nivel de amenaza
void Game::updateMenace()
{
const auto stage = balloon_formations_->getStage(current_stage_);
const float percent = current_power_ / stage.power_to_complete;
const int difference = stage.max_menace - stage.min_menace;
const auto stage = balloon_formations_->getStage(current_stage_);
const float percent = current_power_ / stage.power_to_complete;
const int difference = stage.max_menace - stage.min_menace;
// Aumenta el nivel de amenaza en función de la puntuación
menace_threshold_ = stage.min_menace + (difference * percent);
// Aumenta el nivel de amenaza en función de la puntuación
menace_threshold_ = stage.min_menace + (difference * percent);
// Si el nivel de amenza es inferior al umbral
if (menace_current_ < menace_threshold_)
{
// Crea una formación de enemigos
balloon_manager_->deployBalloonFormation();
// Si el nivel de amenza es inferior al umbral
if (menace_current_ < menace_threshold_)
{
// Crea una formación de enemigos
balloon_manager_->deployBalloonFormation();
// Recalcula el nivel de amenaza con el nuevo globo
evaluateAndSetMenace();
}
// Recalcula el nivel de amenaza con el nuevo globo
evaluateAndSetMenace();
}
}
// Calcula y establece el valor de amenaza en funcion de los globos activos
void Game::evaluateAndSetMenace()
{
menace_current_ = std::accumulate(
balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon)
{ return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
menace_current_ = std::accumulate(
balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon)
{ return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
}

View File

@@ -369,9 +369,6 @@ private:
// Inicializa los jugadores
void initPlayers(int player_id);
// Crea dos globos gordos
void createTwoBigBalloons();
// Pausa la música
void pauseMusic();

20
source/stage.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include "stage.h"
#include <vector>
namespace Stage
{
// Inicializa las fases del juego
void init()
{
stages.emplace_back(Stage(1, 200, 7 + (4 * 1), 7 + (4 * 3)));
stages.emplace_back(Stage(2, 300, 7 + (4 * 2), 7 + (4 * 4)));
stages.emplace_back(Stage(3, 600, 7 + (4 * 3), 7 + (4 * 5)));
stages.emplace_back(Stage(4, 600, 7 + (4 * 3), 7 + (4 * 5)));
stages.emplace_back(Stage(5, 600, 7 + (4 * 4), 7 + (4 * 6)));
stages.emplace_back(Stage(6, 600, 7 + (4 * 4), 7 + (4 * 6)));
stages.emplace_back(Stage(7, 650, 7 + (4 * 5), 7 + (4 * 7)));
stages.emplace_back(Stage(8, 750, 7 + (4 * 5), 7 + (4 * 7)));
stages.emplace_back(Stage(9, 850, 7 + (4 * 6), 7 + (4 * 8)));
stages.emplace_back(Stage(10, 950, 7 + (4 * 7), 7 + (4 * 10)));
}
}

26
source/stage.h Normal file
View File

@@ -0,0 +1,26 @@
#pragma once
#include <vector>
namespace Stage
{
struct Stage
{
int number; // Número de fase
int power_to_complete; // Cantidad de poder que se necesita para completar la fase
int min_menace; // Umbral mínimo de amenaza de la fase
int max_menace; // Umbral máximo de amenaza de la fase
// Constructor
Stage(int number, int power_to_complete, int min_menace, int max_menace)
: number(number), power_to_complete(power_to_complete), min_menace(min_menace), max_menace(max_menace) {}
};
std::vector<Stage> stages; // Variable con los datos de cada pantalla
// Devuelve una fase
Stage get(int index) { return stages.at(index); }
// Inicializa las fases del juego
void init();
}