reestructurat background, balloon_formations i balloon_manager

This commit is contained in:
2025-05-27 13:58:51 +02:00
parent ada141cb09
commit 677e4d465d
3 changed files with 167 additions and 239 deletions

View File

@@ -3,11 +3,13 @@
#include "balloon.h" // Para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include <vector>
// Constantes de configuración
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 de datos
struct BalloonFormationParams
{
int x = 0; // Posición en el eje X donde crear el globo
@@ -30,28 +32,19 @@ struct BalloonFormationUnit
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
// Constructor con parámetros
BalloonFormationUnit(int num_balloons, const std::vector<BalloonFormationParams> &init_params)
: number_of_balloons(num_balloons), init(init_params) {}
// Default constructor
// Constructor por defecto
BalloonFormationUnit() : number_of_balloons(0), init() {}
};
using BalloonFormationPool = std::vector<const BalloonFormationUnit *>;
// Clase BalloonFormations
class BalloonFormations
{
private:
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();
// Inicializa los conjuntos de formaciones
void initBalloonFormationPools();
public:
// Constructor
BalloonFormations()
@@ -67,4 +60,12 @@ public:
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); }
const BalloonFormationUnit &getSet(int set) const { return balloon_formation_.at(set); }
private:
std::vector<BalloonFormationUnit> balloon_formation_; // Vector con todas las formaciones enemigas
std::vector<BalloonFormationPool> balloon_formation_pool_; // Conjuntos de formaciones enemigas
// Métodos internos de inicialización
void initBalloonFormations();
void initBalloonFormationPools();
};