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

@@ -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); }
};