Revisant la classe Balloon

This commit is contained in:
2024-10-26 11:38:08 +02:00
parent d44bfd51de
commit f99f908c11
6 changed files with 415 additions and 449 deletions

View File

@@ -7,7 +7,7 @@
#include "texture.h" // para Texture #include "texture.h" // para Texture
// Constructor // Constructor
Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation) Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)), : sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
pos_x_(x), pos_x_(x),
pos_y_(y), pos_y_(y),
@@ -16,185 +16,191 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
invulnerable_(creation_timer > 0), invulnerable_(creation_timer > 0),
creation_counter_(creation_timer), creation_counter_(creation_timer),
creation_counter_ini_(creation_timer), creation_counter_ini_(creation_timer),
kind_(kind), type_(type),
size_(size),
speed_(speed) speed_(speed)
{ {
switch (type_)
switch (kind_)
{ {
case BALLOON_1: case BalloonType::BALLOON:
// Alto y ancho del objeto {
width_ = BALLOON_WIDTH_1; switch (size_)
height_ = BALLOON_WIDTH_1; {
size_ = BALLOON_SIZE_1; case BalloonSize::SIZE1:
power_ = 1; // Alto y ancho del objeto
width_ = BALLOON_WIDTH_1;
height_ = BALLOON_WIDTH_1;
power_ = 1;
// Inicializa los valores de velocidad y gravedad // Inicializa los valores de velocidad y gravedad
vel_y_ = 0; vel_y_ = 0;
max_vel_y_ = 3.0f; max_vel_y_ = 3.0f;
gravity_ = param.balloon_1.grav; gravity_ = param.balloon_1.grav;
default_vel_y_ = param.balloon_1.vel; default_vel_y_ = param.balloon_1.vel;
// Puntos que da el globo al ser destruido // Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_1; score_ = BALLOON_SCORE_1;
// Amenaza que genera el globo // Amenaza que genera el globo
menace_ = 1; menace_ = 1;
break;
case BalloonSize::SIZE2:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_2;
height_ = BALLOON_WIDTH_2;
power_ = 3;
// Inicializa los valores de velocidad y gravedad
vel_y_ = 0;
max_vel_y_ = 3.0f;
gravity_ = param.balloon_2.grav;
default_vel_y_ = param.balloon_2.vel;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_2;
// Amenaza que genera el globo
menace_ = 2;
break;
case BalloonSize::SIZE3:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_3;
height_ = BALLOON_WIDTH_3;
power_ = 7;
// Inicializa los valores de velocidad y gravedad
vel_y_ = 0;
max_vel_y_ = 3.0f;
gravity_ = param.balloon_3.grav;
default_vel_y_ = param.balloon_3.vel;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_3;
// Amenaza que genera el globo
menace_ = 4;
break;
case BalloonSize::SIZE4:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_4;
height_ = BALLOON_WIDTH_4;
power_ = 15;
// Inicializa los valores de velocidad y gravedad
vel_y_ = 0;
max_vel_y_ = 3.0f;
gravity_ = param.balloon_4.grav;
default_vel_y_ = param.balloon_4.vel;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_4;
// Amenaza que genera el globo
menace_ = 8;
break;
}
break; break;
}
case BALLOON_2: case BalloonType::HEXAGON:
// Alto y ancho del objeto {
width_ = BALLOON_WIDTH_2; switch (size_)
height_ = BALLOON_WIDTH_2; {
size_ = BALLOON_SIZE_2; case BalloonSize::SIZE1:
power_ = 3; // Alto y ancho del objeto
width_ = BALLOON_WIDTH_1;
height_ = BALLOON_WIDTH_1;
power_ = 1;
// Inicializa los valores de velocidad y gravedad // Inicializa los valores de velocidad y gravedad
vel_y_ = 0; vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = 3.0f; max_vel_y_ = vel_y_;
gravity_ = param.balloon_2.grav; gravity_ = 0.00f;
default_vel_y_ = param.balloon_2.vel; default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido // Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_2; score_ = BALLOON_SCORE_1;
// Amenaza que genera el globo // Amenaza que genera el globo
menace_ = 2; menace_ = 1;
break;
case BalloonSize::SIZE2:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_2;
height_ = BALLOON_WIDTH_2;
power_ = 3;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_2;
// Amenaza que genera el globo
menace_ = 2;
break;
case BalloonSize::SIZE3:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_3;
height_ = BALLOON_WIDTH_3;
power_ = 7;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_3;
// Amenaza que genera el globo
menace_ = 4;
break;
case BalloonSize::SIZE4:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_4;
height_ = BALLOON_WIDTH_4;
power_ = 15;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_4;
// Amenaza que genera el globo
menace_ = 8;
break;
}
break; break;
}
case BALLOON_3: case BalloonType::POWERBALL:
// Alto y ancho del objeto {
width_ = BALLOON_WIDTH_3;
height_ = BALLOON_WIDTH_3;
size_ = BALLOON_SIZE_3;
power_ = 7;
// Inicializa los valores de velocidad y gravedad
vel_y_ = 0;
max_vel_y_ = 3.0f;
gravity_ = param.balloon_3.grav;
default_vel_y_ = param.balloon_3.vel;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_3;
// Amenaza que genera el globo
menace_ = 4;
break;
case BALLOON_4:
// Alto y ancho del objeto // Alto y ancho del objeto
width_ = BALLOON_WIDTH_4; width_ = BALLOON_WIDTH_4;
height_ = BALLOON_WIDTH_4; height_ = BALLOON_WIDTH_4;
size_ = BALLOON_SIZE_4;
power_ = 15;
// Inicializa los valores de velocidad y gravedad
vel_y_ = 0;
max_vel_y_ = 3.0f;
gravity_ = param.balloon_4.grav;
default_vel_y_ = param.balloon_4.vel;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_4;
// Amenaza que genera el globo
menace_ = 8;
break;
case HEXAGON_1:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_1;
height_ = BALLOON_WIDTH_1;
size_ = BALLOON_SIZE_1;
power_ = 1;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_1;
// Amenaza que genera el globo
menace_ = 1;
break;
case HEXAGON_2:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_2;
height_ = BALLOON_WIDTH_2;
size_ = BALLOON_SIZE_2;
power_ = 3;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_2;
// Amenaza que genera el globo
menace_ = 2;
break;
case HEXAGON_3:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_3;
height_ = BALLOON_WIDTH_3;
size_ = BALLOON_SIZE_3;
power_ = 7;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_3;
// Amenaza que genera el globo
menace_ = 4;
break;
case HEXAGON_4:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_4;
height_ = BALLOON_WIDTH_4;
size_ = BALLOON_SIZE_4;
power_ = 15;
// Inicializa los valores de velocidad y gravedad
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_4;
// Amenaza que genera el globo
menace_ = 8;
break;
case POWER_BALL:
// Alto y ancho del objeto
width_ = BALLOON_WIDTH_4;
height_ = BALLOON_WIDTH_4;
size_ = 4;
power_ = 0; power_ = 0;
// Inicializa los valores de velocidad y gravedad // Inicializa los valores de velocidad y gravedad
@@ -213,8 +219,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
sprite_->disableRotate(); sprite_->disableRotate();
sprite_->setRotateSpeed(0); sprite_->setRotateSpeed(0);
vel_x_ > 0.0f ? sprite_->setRotateAmount(2.0) : sprite_->setRotateAmount(-2.0); vel_x_ > 0.0f ? sprite_->setRotateAmount(2.0) : sprite_->setRotateAmount(-2.0);
break; break;
}
default: default:
break; break;
@@ -270,7 +276,7 @@ void Balloon::render()
{ {
if (bouncing_.enabled) if (bouncing_.enabled)
{ {
if (kind_ != POWER_BALL) if (type_ != BalloonType::POWERBALL)
{ {
// Aplica desplazamiento para el zoom // Aplica desplazamiento para el zoom
sprite_->setPosX(getPosX() + bouncing_.despX); sprite_->setPosX(getPosX() + bouncing_.despX);
@@ -292,7 +298,7 @@ void Balloon::render()
sprite_->render(); sprite_->render();
} }
if (kind_ == POWER_BALL && !isBeingCreated()) if (type_ == BalloonType::POWERBALL && !isBeingCreated())
{ {
auto sp = std::make_unique<Sprite>(sprite_->getTexture(), sprite_->getPosition()); auto sp = std::make_unique<Sprite>(sprite_->getTexture(), sprite_->getPosition());
sp->setSpriteClip(BALLOON_WIDTH_4, 0, BALLOON_WIDTH_4, BALLOON_WIDTH_4); sp->setSpriteClip(BALLOON_WIDTH_4, 0, BALLOON_WIDTH_4, BALLOON_WIDTH_4);
@@ -323,7 +329,7 @@ void Balloon::move()
sprite_->switchRotate(); sprite_->switchRotate();
// Activa el efecto de rebote // Activa el efecto de rebote
if (kind_ != POWER_BALL) if (type_ != BalloonType::POWERBALL)
{ {
bounceStart(); bounceStart();
} }
@@ -342,7 +348,7 @@ void Balloon::move()
vel_y_ = -vel_y_; vel_y_ = -vel_y_;
// Activa el efecto de rebote // Activa el efecto de rebote
if (kind_ != POWER_BALL) if (type_ != BalloonType::POWERBALL)
{ {
bounceStart(); bounceStart();
} }
@@ -358,7 +364,7 @@ void Balloon::move()
vel_y_ = -default_vel_y_; vel_y_ = -default_vel_y_;
// Activa el efecto de rebote // Activa el efecto de rebote
if (kind_ != POWER_BALL) if (type_ != BalloonType::POWERBALL)
{ {
bounceStart(); bounceStart();
} }
@@ -408,14 +414,12 @@ void Balloon::disable()
gravity_ = 0.0f; gravity_ = 0.0f;
height_ = 0; height_ = 0;
invulnerable_ = false; invulnerable_ = false;
kind_ = 0;
max_vel_y_ = 0.0f; max_vel_y_ = 0.0f;
menace_ = 0; menace_ = 0;
pos_x_ = 0.0f; pos_x_ = 0.0f;
pos_y_ = 0.0f; pos_y_ = 0.0f;
power_ = 0; power_ = 0;
score_ = 0; score_ = 0;
size_ = 0;
speed_ = 0; speed_ = 0;
stopped_ = false; stopped_ = false;
stopped_counter_ = 0; stopped_counter_ = 0;
@@ -492,7 +496,7 @@ void Balloon::updateState()
setStop(false); setStop(false);
setVisible(true); setVisible(true);
setInvulnerable(false); setInvulnerable(false);
if (kind_ == POWER_BALL) if (type_ == BalloonType::POWERBALL)
{ {
sprite_->enableRotate(); sprite_->enableRotate();
} }
@@ -502,7 +506,7 @@ void Balloon::updateState()
else if (isStopped()) else if (isStopped())
{ {
// Si es una powerball deja de rodar // Si es una powerball deja de rodar
if (kind_ == POWER_BALL) if (type_ == BalloonType::POWERBALL)
{ {
sprite_->disableRotate(); sprite_->disableRotate();
} }
@@ -518,7 +522,7 @@ void Balloon::updateState()
setStop(false); setStop(false);
// Si es una powerball vuelve a rodar // Si es una powerball vuelve a rodar
if (kind_ == POWER_BALL) if (type_ == BalloonType::POWERBALL)
{ {
sprite_->enableRotate(); sprite_->enableRotate();
} }
@@ -532,27 +536,19 @@ void Balloon::updateAnimation()
std::string creating_animation = "blue"; std::string creating_animation = "blue";
std::string normal_animation = "orange"; std::string normal_animation = "orange";
if (kind_ == POWER_BALL) if (type_ == BalloonType::POWERBALL)
{ {
creating_animation = "powerball"; creating_animation = "powerball";
normal_animation = "powerball"; normal_animation = "powerball";
} }
else if (getClass() == HEXAGON_CLASS) else if (type_ == BalloonType::HEXAGON)
{ {
creating_animation = "red"; creating_animation = "red";
normal_animation = "green"; normal_animation = "green";
} }
// Establece el frame de animación // Establece el frame de animación
if (isBeingCreated()) sprite_->setCurrentAnimation(isBeingCreated() ? creating_animation : normal_animation);
{
sprite_->setCurrentAnimation(creating_animation);
}
else
{
sprite_->setCurrentAnimation(normal_animation);
}
sprite_->update(); sprite_->update();
} }
@@ -604,32 +600,16 @@ void Balloon::setSpeed(float speed)
speed_ = speed; speed_ = speed;
} }
// Obtiene del valor de la variable // Obtiene el tamaño del globo
int Balloon::getKind() const BalloonSize Balloon::getSize() const
{
return kind_;
}
// Obtiene del valor de la variable
Uint8 Balloon::getSize() const
{ {
return size_; return size_;
} }
// Obtiene la clase a la que pertenece el globo // Obtiene el tipo de globo
Uint8 Balloon::getClass() const BalloonType Balloon::getType() const
{ {
if ((kind_ >= BALLOON_1) && (kind_ <= BALLOON_4)) return type_;
{
return BALLOON_CLASS;
}
else if ((kind_ >= HEXAGON_1) && (kind_ <= HEXAGON_4))
{
return HEXAGON_CLASS;
}
return BALLOON_CLASS;
} }
// Establece el valor de la variable // Establece el valor de la variable

View File

@@ -11,17 +11,6 @@ class Texture;
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar // Cantidad de elementos del vector con los valores de la deformación del globo al rebotar
constexpr int MAX_BOUNCE = 10; constexpr int MAX_BOUNCE = 10;
// Tipos de globo
constexpr int BALLOON_1 = 1;
constexpr int BALLOON_2 = 2;
constexpr int BALLOON_3 = 3;
constexpr int BALLOON_4 = 4;
constexpr int HEXAGON_1 = 5;
constexpr int HEXAGON_2 = 6;
constexpr int HEXAGON_3 = 7;
constexpr int HEXAGON_4 = 8;
constexpr int POWER_BALL = 9;
// Puntos de globo // Puntos de globo
constexpr int BALLOON_SCORE_1 = 50; constexpr int BALLOON_SCORE_1 = 50;
constexpr int BALLOON_SCORE_2 = 100; constexpr int BALLOON_SCORE_2 = 100;
@@ -29,14 +18,21 @@ constexpr int BALLOON_SCORE_3 = 200;
constexpr int BALLOON_SCORE_4 = 400; constexpr int BALLOON_SCORE_4 = 400;
// Tamaños de globo // Tamaños de globo
constexpr int BALLOON_SIZE_1 = 1; enum class BalloonSize : Uint8
constexpr int BALLOON_SIZE_2 = 2; {
constexpr int BALLOON_SIZE_3 = 3; SIZE1 = 0,
constexpr int BALLOON_SIZE_4 = 4; SIZE2 = 1,
SIZE3 = 2,
SIZE4 = 3,
};
// Clases de globo // Clases de globo
constexpr int BALLOON_CLASS = 0; enum class BalloonType : Uint8
constexpr int HEXAGON_CLASS = 1; {
BALLOON = 0,
HEXAGON = 1,
POWERBALL = 2,
};
// Velocidad del globo // Velocidad del globo
constexpr float BALLOON_VELX_POSITIVE = 0.7f; constexpr float BALLOON_VELX_POSITIVE = 0.7f;
@@ -106,12 +102,12 @@ private:
Uint16 creation_counter_ini_; // Valor inicial para el temporizador para controlar el estado "creandose" Uint16 creation_counter_ini_; // Valor inicial para el temporizador para controlar el estado "creandose"
Uint16 score_; // Puntos que da el globo al ser destruido Uint16 score_; // Puntos que da el globo al ser destruido
Uint16 stopped_counter_ = 0; // Contador para controlar el estado "parado" Uint16 stopped_counter_ = 0; // Contador para controlar el estado "parado"
Uint8 kind_; // Tipo de globo BalloonType type_; // Clase de globo
BalloonSize size_; // Tamaño del globo
Uint8 menace_; // Cantidad de amenaza que genera el globo Uint8 menace_; // Cantidad de amenaza que genera el globo
Uint32 counter_ = 0; // Contador interno Uint32 counter_ = 0; // Contador interno
float travel_y_ = 1.0f; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad float travel_y_ = 1.0f; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
float speed_; // Velocidad a la que se mueven los globos float speed_; // Velocidad a la que se mueven los globos
Uint8 size_; // Tamaño del globo
Uint8 power_; // Cantidad de poder que alberga el globo Uint8 power_; // Cantidad de poder que alberga el globo
Bouncing bouncing_; // Contiene las variables para el efecto de rebote Bouncing bouncing_; // Contiene las variables para el efecto de rebote
@@ -138,7 +134,7 @@ private:
public: public:
// Constructor // Constructor
Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation); Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation);
// Destructor // Destructor
~Balloon() = default; ~Balloon() = default;
@@ -185,14 +181,11 @@ public:
// Establece el valor de la variable // Establece el valor de la variable
void setSpeed(float speed); void setSpeed(float speed);
// Obtiene del valor de la variable // Obtiene el tamaño del globo
int getKind() const; BalloonSize getSize() const;
// Obtiene del valor de la variable // Obtiene el tipo de globo
Uint8 getSize() const; BalloonType getType() const;
// Obtiene la clase a la que pertenece el globo
Uint8 getClass() const;
// Establece el valor de la variable // Establece el valor de la variable
void setStop(bool value); void setStop(bool value);

View File

@@ -32,12 +32,12 @@ void BalloonFormations::initBalloonFormations()
const int x1_100 = param.game.play_area.rect.w - BALLOON_WIDTH_1; const int x1_100 = param.game.play_area.rect.w - BALLOON_WIDTH_1;
// Inicializa a cero las variables // Inicializa a cero las variables
for (int i = 0; i < NUMBER_OF_BALLOON_FORMATIONS; i++) for (int j = 0; j < NUMBER_OF_BALLOON_FORMATIONS; ++j)
{ {
balloon_formation_[i].number_of_balloons = 0; balloon_formation_[j].number_of_balloons = 0;
for (int j = 0; j < MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION; j++) for (int i = 0; i < MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION; ++i)
{ {
balloon_formation_[i].init[j] = BalloonFormationParams(); balloon_formation_[j].init[i] = BalloonFormationParams();
} }
} }
@@ -56,7 +56,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x4_0 + (i * inc_x); balloon_formation_[j].init[i].x = x4_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y4; 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].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
balloon_formation_[j].init[i].kind = BALLOON_4; balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
} }
@@ -70,7 +70,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = param.game.play_area.first_quarter_x - (BALLOON_WIDTH_4 / 2) + (i * inc_x); balloon_formation_[j].init[i].x = param.game.play_area.first_quarter_x - (BALLOON_WIDTH_4 / 2) + (i * inc_x);
balloon_formation_[j].init[i].y = y4; 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].vel_x = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
balloon_formation_[j].init[i].kind = BALLOON_4; balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
} }
@@ -84,7 +84,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x2_0 + (i * inc_x); balloon_formation_[j].init[i].x = x2_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y2; balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_2; balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -98,7 +98,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x2_100 - (i * inc_x); balloon_formation_[j].init[i].x = x2_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y2; balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_2; balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -112,7 +112,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x); balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -126,7 +126,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x); balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -140,7 +140,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x); balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -154,7 +154,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x); balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -168,7 +168,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x1_0 + (i * inc_x); balloon_formation_[j].init[i].x = x1_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y1; balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -182,7 +182,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x1_100 - (i * inc_x); balloon_formation_[j].init[i].x = x1_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y1; balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -196,7 +196,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x4_0 + (i * inc_x); balloon_formation_[j].init[i].x = x4_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y4; balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_4; balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -210,7 +210,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x4_100 - (i * inc_x); balloon_formation_[j].init[i].x = x4_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y4; balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_4; balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -224,7 +224,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x2_0 + (i * inc_x); balloon_formation_[j].init[i].x = x2_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y2; balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_2; balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -238,7 +238,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x2_100 - (i * inc_x); balloon_formation_[j].init[i].x = x2_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y2; balloon_formation_[j].init[i].y = y2;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_2; balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -252,7 +252,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x); balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -266,7 +266,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x); balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -280,7 +280,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_0 + (i * inc_x); balloon_formation_[j].init[i].x = x3_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -294,7 +294,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x3_100 - (i * inc_x); balloon_formation_[j].init[i].x = x3_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y3; balloon_formation_[j].init[i].y = y3;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -308,7 +308,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x1_0 + (i * inc_x); balloon_formation_[j].init[i].x = x1_0 + (i * inc_x);
balloon_formation_[j].init[i].y = y1; balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -322,7 +322,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].x = x1_100 - (i * inc_x); balloon_formation_[j].init[i].x = x1_100 - (i * inc_x);
balloon_formation_[j].init[i].y = y1; balloon_formation_[j].init[i].y = y1;
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
} }
@@ -345,7 +345,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE; balloon_formation_[j].init[i].vel_x = BALLOON_VELX_NEGATIVE;
} }
balloon_formation_[j].init[i].y = y4; balloon_formation_[j].init[i].y = y4;
balloon_formation_[j].init[i].kind = BALLOON_4; balloon_formation_[j].init[i].size = BalloonSize::SIZE4;
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
} }
@@ -370,7 +370,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); 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].y = y2;
balloon_formation_[j].init[i].kind = BALLOON_2; balloon_formation_[j].init[i].size = BalloonSize::SIZE2;
} }
// #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simetricos // #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simetricos
@@ -394,7 +394,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); 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].y = y3;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
} }
// #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simetricos // #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simetricos
@@ -418,7 +418,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); 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].y = y3;
balloon_formation_[j].init[i].kind = BALLOON_3; balloon_formation_[j].init[i].size = BalloonSize::SIZE3;
} }
// #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos // #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos
@@ -441,7 +441,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * (i - half)); 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].y = y1;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
} }
// #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simetricos // #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simetricos
@@ -464,7 +464,7 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); 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].y = y1;
balloon_formation_[j].init[i].kind = BALLOON_1; balloon_formation_[j].init[i].size = BalloonSize::SIZE1;
} }
// Crea las mismas formaciones pero con hexagonos a partir de la posición 50 del vector // Crea las mismas formaciones pero con hexagonos a partir de la posición 50 del vector
@@ -477,7 +477,8 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[k + 50].init[i].y = balloon_formation_[k].init[i].y; 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].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].creation_counter = balloon_formation_[k].init[i].creation_counter;
balloon_formation_[k + 50].init[i].kind = balloon_formation_[k].init[i].kind + 4; balloon_formation_[k + 50].init[i].size = balloon_formation_[k].init[i].size;
balloon_formation_[k + 50].init[i].type = BalloonType::HEXAGON;
} }
} }
@@ -487,25 +488,25 @@ void BalloonFormations::initBalloonFormations()
balloon_formation_[99].init[0].x = 10; balloon_formation_[99].init[0].x = 10;
balloon_formation_[99].init[0].y = y1; balloon_formation_[99].init[0].y = y1;
balloon_formation_[99].init[0].vel_x = 0; balloon_formation_[99].init[0].vel_x = 0;
balloon_formation_[99].init[0].kind = BALLOON_1; balloon_formation_[99].init[0].size = BalloonSize::SIZE1;
balloon_formation_[99].init[0].creation_counter = 200; balloon_formation_[99].init[0].creation_counter = 200;
balloon_formation_[99].init[1].x = 50; balloon_formation_[99].init[1].x = 50;
balloon_formation_[99].init[1].y = y1; balloon_formation_[99].init[1].y = y1;
balloon_formation_[99].init[1].vel_x = 0; balloon_formation_[99].init[1].vel_x = 0;
balloon_formation_[99].init[1].kind = BALLOON_2; balloon_formation_[99].init[1].size = BalloonSize::SIZE2;
balloon_formation_[99].init[1].creation_counter = 200; balloon_formation_[99].init[1].creation_counter = 200;
balloon_formation_[99].init[2].x = 90; balloon_formation_[99].init[2].x = 90;
balloon_formation_[99].init[2].y = y1; balloon_formation_[99].init[2].y = y1;
balloon_formation_[99].init[2].vel_x = 0; balloon_formation_[99].init[2].vel_x = 0;
balloon_formation_[99].init[2].kind = BALLOON_3; balloon_formation_[99].init[2].size = BalloonSize::SIZE3;
balloon_formation_[99].init[2].creation_counter = 200; balloon_formation_[99].init[2].creation_counter = 200;
balloon_formation_[99].init[3].x = 140; balloon_formation_[99].init[3].x = 140;
balloon_formation_[99].init[3].y = y1; balloon_formation_[99].init[3].y = y1;
balloon_formation_[99].init[3].vel_x = 0; balloon_formation_[99].init[3].vel_x = 0;
balloon_formation_[99].init[3].kind = BALLOON_4; balloon_formation_[99].init[3].size = BalloonSize::SIZE4;
balloon_formation_[99].init[3].creation_counter = 200; balloon_formation_[99].init[3].creation_counter = 200;
} }
@@ -513,124 +514,124 @@ void BalloonFormations::initBalloonFormations()
void BalloonFormations::initBalloonFormationPools() void BalloonFormations::initBalloonFormationPools()
{ {
// EnemyPool #0 // EnemyPool #0
balloon_formation_pool_[0].set[0] = &balloon_formation_[0]; balloon_formation_pool_[0].set[0] = balloon_formation_[0];
balloon_formation_pool_[0].set[1] = &balloon_formation_[1]; balloon_formation_pool_[0].set[1] = balloon_formation_[1];
balloon_formation_pool_[0].set[2] = &balloon_formation_[2]; balloon_formation_pool_[0].set[2] = balloon_formation_[2];
balloon_formation_pool_[0].set[3] = &balloon_formation_[3]; balloon_formation_pool_[0].set[3] = balloon_formation_[3];
balloon_formation_pool_[0].set[4] = &balloon_formation_[4]; balloon_formation_pool_[0].set[4] = balloon_formation_[4];
balloon_formation_pool_[0].set[5] = &balloon_formation_[5]; balloon_formation_pool_[0].set[5] = balloon_formation_[5];
balloon_formation_pool_[0].set[6] = &balloon_formation_[6]; balloon_formation_pool_[0].set[6] = balloon_formation_[6];
balloon_formation_pool_[0].set[7] = &balloon_formation_[7]; balloon_formation_pool_[0].set[7] = balloon_formation_[7];
balloon_formation_pool_[0].set[8] = &balloon_formation_[8]; balloon_formation_pool_[0].set[8] = balloon_formation_[8];
balloon_formation_pool_[0].set[9] = &balloon_formation_[9]; balloon_formation_pool_[0].set[9] = balloon_formation_[9];
// EnemyPool #1 // EnemyPool #1
balloon_formation_pool_[1].set[0] = &balloon_formation_[10]; balloon_formation_pool_[1].set[0] = balloon_formation_[10];
balloon_formation_pool_[1].set[1] = &balloon_formation_[11]; balloon_formation_pool_[1].set[1] = balloon_formation_[11];
balloon_formation_pool_[1].set[2] = &balloon_formation_[12]; balloon_formation_pool_[1].set[2] = balloon_formation_[12];
balloon_formation_pool_[1].set[3] = &balloon_formation_[13]; balloon_formation_pool_[1].set[3] = balloon_formation_[13];
balloon_formation_pool_[1].set[4] = &balloon_formation_[14]; balloon_formation_pool_[1].set[4] = balloon_formation_[14];
balloon_formation_pool_[1].set[5] = &balloon_formation_[15]; balloon_formation_pool_[1].set[5] = balloon_formation_[15];
balloon_formation_pool_[1].set[6] = &balloon_formation_[16]; balloon_formation_pool_[1].set[6] = balloon_formation_[16];
balloon_formation_pool_[1].set[7] = &balloon_formation_[17]; balloon_formation_pool_[1].set[7] = balloon_formation_[17];
balloon_formation_pool_[1].set[8] = &balloon_formation_[18]; balloon_formation_pool_[1].set[8] = balloon_formation_[18];
balloon_formation_pool_[1].set[9] = &balloon_formation_[19]; balloon_formation_pool_[1].set[9] = balloon_formation_[19];
// EnemyPool #2 // EnemyPool #2
balloon_formation_pool_[2].set[0] = &balloon_formation_[0]; balloon_formation_pool_[2].set[0] = balloon_formation_[0];
balloon_formation_pool_[2].set[1] = &balloon_formation_[1]; balloon_formation_pool_[2].set[1] = balloon_formation_[1];
balloon_formation_pool_[2].set[2] = &balloon_formation_[2]; balloon_formation_pool_[2].set[2] = balloon_formation_[2];
balloon_formation_pool_[2].set[3] = &balloon_formation_[3]; balloon_formation_pool_[2].set[3] = balloon_formation_[3];
balloon_formation_pool_[2].set[4] = &balloon_formation_[4]; balloon_formation_pool_[2].set[4] = balloon_formation_[4];
balloon_formation_pool_[2].set[5] = &balloon_formation_[55]; balloon_formation_pool_[2].set[5] = balloon_formation_[55];
balloon_formation_pool_[2].set[6] = &balloon_formation_[56]; balloon_formation_pool_[2].set[6] = balloon_formation_[56];
balloon_formation_pool_[2].set[7] = &balloon_formation_[57]; balloon_formation_pool_[2].set[7] = balloon_formation_[57];
balloon_formation_pool_[2].set[8] = &balloon_formation_[58]; balloon_formation_pool_[2].set[8] = balloon_formation_[58];
balloon_formation_pool_[2].set[9] = &balloon_formation_[59]; balloon_formation_pool_[2].set[9] = balloon_formation_[59];
// EnemyPool #3 // EnemyPool #3
balloon_formation_pool_[3].set[0] = &balloon_formation_[50]; balloon_formation_pool_[3].set[0] = balloon_formation_[50];
balloon_formation_pool_[3].set[1] = &balloon_formation_[51]; balloon_formation_pool_[3].set[1] = balloon_formation_[51];
balloon_formation_pool_[3].set[2] = &balloon_formation_[52]; balloon_formation_pool_[3].set[2] = balloon_formation_[52];
balloon_formation_pool_[3].set[3] = &balloon_formation_[53]; balloon_formation_pool_[3].set[3] = balloon_formation_[53];
balloon_formation_pool_[3].set[4] = &balloon_formation_[54]; balloon_formation_pool_[3].set[4] = balloon_formation_[54];
balloon_formation_pool_[3].set[5] = &balloon_formation_[5]; balloon_formation_pool_[3].set[5] = balloon_formation_[5];
balloon_formation_pool_[3].set[6] = &balloon_formation_[6]; balloon_formation_pool_[3].set[6] = balloon_formation_[6];
balloon_formation_pool_[3].set[7] = &balloon_formation_[7]; balloon_formation_pool_[3].set[7] = balloon_formation_[7];
balloon_formation_pool_[3].set[8] = &balloon_formation_[8]; balloon_formation_pool_[3].set[8] = balloon_formation_[8];
balloon_formation_pool_[3].set[9] = &balloon_formation_[9]; balloon_formation_pool_[3].set[9] = balloon_formation_[9];
// EnemyPool #4 // EnemyPool #4
balloon_formation_pool_[4].set[0] = &balloon_formation_[60]; balloon_formation_pool_[4].set[0] = balloon_formation_[60];
balloon_formation_pool_[4].set[1] = &balloon_formation_[61]; balloon_formation_pool_[4].set[1] = balloon_formation_[61];
balloon_formation_pool_[4].set[2] = &balloon_formation_[62]; balloon_formation_pool_[4].set[2] = balloon_formation_[62];
balloon_formation_pool_[4].set[3] = &balloon_formation_[63]; balloon_formation_pool_[4].set[3] = balloon_formation_[63];
balloon_formation_pool_[4].set[4] = &balloon_formation_[64]; balloon_formation_pool_[4].set[4] = balloon_formation_[64];
balloon_formation_pool_[4].set[5] = &balloon_formation_[65]; balloon_formation_pool_[4].set[5] = balloon_formation_[65];
balloon_formation_pool_[4].set[6] = &balloon_formation_[66]; balloon_formation_pool_[4].set[6] = balloon_formation_[66];
balloon_formation_pool_[4].set[7] = &balloon_formation_[67]; balloon_formation_pool_[4].set[7] = balloon_formation_[67];
balloon_formation_pool_[4].set[8] = &balloon_formation_[68]; balloon_formation_pool_[4].set[8] = balloon_formation_[68];
balloon_formation_pool_[4].set[9] = &balloon_formation_[69]; balloon_formation_pool_[4].set[9] = balloon_formation_[69];
// EnemyPool #5 // EnemyPool #5
balloon_formation_pool_[5].set[0] = &balloon_formation_[10]; balloon_formation_pool_[5].set[0] = balloon_formation_[10];
balloon_formation_pool_[5].set[1] = &balloon_formation_[61]; balloon_formation_pool_[5].set[1] = balloon_formation_[61];
balloon_formation_pool_[5].set[2] = &balloon_formation_[12]; balloon_formation_pool_[5].set[2] = balloon_formation_[12];
balloon_formation_pool_[5].set[3] = &balloon_formation_[63]; balloon_formation_pool_[5].set[3] = balloon_formation_[63];
balloon_formation_pool_[5].set[4] = &balloon_formation_[14]; balloon_formation_pool_[5].set[4] = balloon_formation_[14];
balloon_formation_pool_[5].set[5] = &balloon_formation_[65]; balloon_formation_pool_[5].set[5] = balloon_formation_[65];
balloon_formation_pool_[5].set[6] = &balloon_formation_[16]; balloon_formation_pool_[5].set[6] = balloon_formation_[16];
balloon_formation_pool_[5].set[7] = &balloon_formation_[67]; balloon_formation_pool_[5].set[7] = balloon_formation_[67];
balloon_formation_pool_[5].set[8] = &balloon_formation_[18]; balloon_formation_pool_[5].set[8] = balloon_formation_[18];
balloon_formation_pool_[5].set[9] = &balloon_formation_[69]; balloon_formation_pool_[5].set[9] = balloon_formation_[69];
// EnemyPool #6 // EnemyPool #6
balloon_formation_pool_[6].set[0] = &balloon_formation_[60]; balloon_formation_pool_[6].set[0] = balloon_formation_[60];
balloon_formation_pool_[6].set[1] = &balloon_formation_[11]; balloon_formation_pool_[6].set[1] = balloon_formation_[11];
balloon_formation_pool_[6].set[2] = &balloon_formation_[62]; balloon_formation_pool_[6].set[2] = balloon_formation_[62];
balloon_formation_pool_[6].set[3] = &balloon_formation_[13]; balloon_formation_pool_[6].set[3] = balloon_formation_[13];
balloon_formation_pool_[6].set[4] = &balloon_formation_[64]; balloon_formation_pool_[6].set[4] = balloon_formation_[64];
balloon_formation_pool_[6].set[5] = &balloon_formation_[15]; balloon_formation_pool_[6].set[5] = balloon_formation_[15];
balloon_formation_pool_[6].set[6] = &balloon_formation_[66]; balloon_formation_pool_[6].set[6] = balloon_formation_[66];
balloon_formation_pool_[6].set[7] = &balloon_formation_[17]; balloon_formation_pool_[6].set[7] = balloon_formation_[17];
balloon_formation_pool_[6].set[8] = &balloon_formation_[68]; balloon_formation_pool_[6].set[8] = balloon_formation_[68];
balloon_formation_pool_[6].set[9] = &balloon_formation_[19]; balloon_formation_pool_[6].set[9] = balloon_formation_[19];
// EnemyPool #7 // EnemyPool #7
balloon_formation_pool_[7].set[0] = &balloon_formation_[20]; balloon_formation_pool_[7].set[0] = balloon_formation_[20];
balloon_formation_pool_[7].set[1] = &balloon_formation_[21]; balloon_formation_pool_[7].set[1] = balloon_formation_[21];
balloon_formation_pool_[7].set[2] = &balloon_formation_[22]; balloon_formation_pool_[7].set[2] = balloon_formation_[22];
balloon_formation_pool_[7].set[3] = &balloon_formation_[23]; balloon_formation_pool_[7].set[3] = balloon_formation_[23];
balloon_formation_pool_[7].set[4] = &balloon_formation_[24]; balloon_formation_pool_[7].set[4] = balloon_formation_[24];
balloon_formation_pool_[7].set[5] = &balloon_formation_[65]; balloon_formation_pool_[7].set[5] = balloon_formation_[65];
balloon_formation_pool_[7].set[6] = &balloon_formation_[66]; balloon_formation_pool_[7].set[6] = balloon_formation_[66];
balloon_formation_pool_[7].set[7] = &balloon_formation_[67]; balloon_formation_pool_[7].set[7] = balloon_formation_[67];
balloon_formation_pool_[7].set[8] = &balloon_formation_[68]; balloon_formation_pool_[7].set[8] = balloon_formation_[68];
balloon_formation_pool_[7].set[9] = &balloon_formation_[69]; balloon_formation_pool_[7].set[9] = balloon_formation_[69];
// EnemyPool #8 // EnemyPool #8
balloon_formation_pool_[8].set[0] = &balloon_formation_[70]; balloon_formation_pool_[8].set[0] = balloon_formation_[70];
balloon_formation_pool_[8].set[1] = &balloon_formation_[71]; balloon_formation_pool_[8].set[1] = balloon_formation_[71];
balloon_formation_pool_[8].set[2] = &balloon_formation_[72]; balloon_formation_pool_[8].set[2] = balloon_formation_[72];
balloon_formation_pool_[8].set[3] = &balloon_formation_[73]; balloon_formation_pool_[8].set[3] = balloon_formation_[73];
balloon_formation_pool_[8].set[4] = &balloon_formation_[74]; balloon_formation_pool_[8].set[4] = balloon_formation_[74];
balloon_formation_pool_[8].set[5] = &balloon_formation_[15]; balloon_formation_pool_[8].set[5] = balloon_formation_[15];
balloon_formation_pool_[8].set[6] = &balloon_formation_[16]; balloon_formation_pool_[8].set[6] = balloon_formation_[16];
balloon_formation_pool_[8].set[7] = &balloon_formation_[17]; balloon_formation_pool_[8].set[7] = balloon_formation_[17];
balloon_formation_pool_[8].set[8] = &balloon_formation_[18]; balloon_formation_pool_[8].set[8] = balloon_formation_[18];
balloon_formation_pool_[8].set[9] = &balloon_formation_[19]; balloon_formation_pool_[8].set[9] = balloon_formation_[19];
// EnemyPool #9 // EnemyPool #9
balloon_formation_pool_[9].set[0] = &balloon_formation_[20]; balloon_formation_pool_[9].set[0] = balloon_formation_[20];
balloon_formation_pool_[9].set[1] = &balloon_formation_[21]; balloon_formation_pool_[9].set[1] = balloon_formation_[21];
balloon_formation_pool_[9].set[2] = &balloon_formation_[22]; balloon_formation_pool_[9].set[2] = balloon_formation_[22];
balloon_formation_pool_[9].set[3] = &balloon_formation_[23]; balloon_formation_pool_[9].set[3] = balloon_formation_[23];
balloon_formation_pool_[9].set[4] = &balloon_formation_[24]; balloon_formation_pool_[9].set[4] = balloon_formation_[24];
balloon_formation_pool_[9].set[5] = &balloon_formation_[70]; balloon_formation_pool_[9].set[5] = balloon_formation_[70];
balloon_formation_pool_[9].set[6] = &balloon_formation_[71]; balloon_formation_pool_[9].set[6] = balloon_formation_[71];
balloon_formation_pool_[9].set[7] = &balloon_formation_[72]; balloon_formation_pool_[9].set[7] = balloon_formation_[72];
balloon_formation_pool_[9].set[8] = &balloon_formation_[73]; balloon_formation_pool_[9].set[8] = balloon_formation_[73];
balloon_formation_pool_[9].set[9] = &balloon_formation_[74]; balloon_formation_pool_[9].set[9] = balloon_formation_[74];
} }
// Inicializa las fases del juego // Inicializa las fases del juego
@@ -641,70 +642,70 @@ void BalloonFormations::initGameStages()
stage_[0].power_to_complete = 200; stage_[0].power_to_complete = 200;
stage_[0].min_menace = 7 + (4 * 1); stage_[0].min_menace = 7 + (4 * 1);
stage_[0].max_menace = 7 + (4 * 3); stage_[0].max_menace = 7 + (4 * 3);
stage_[0].balloon_pool = &balloon_formation_pool_[0]; stage_[0].balloon_pool = balloon_formation_pool_[0];
// STAGE 2 // STAGE 2
stage_[1].number = 2; stage_[1].number = 2;
stage_[1].power_to_complete = 300; stage_[1].power_to_complete = 300;
stage_[1].min_menace = 7 + (4 * 2); stage_[1].min_menace = 7 + (4 * 2);
stage_[1].max_menace = 7 + (4 * 4); stage_[1].max_menace = 7 + (4 * 4);
stage_[1].balloon_pool = &balloon_formation_pool_[1]; stage_[1].balloon_pool = balloon_formation_pool_[1];
// STAGE 3 // STAGE 3
stage_[2].number = 3; stage_[2].number = 3;
stage_[2].power_to_complete = 600; stage_[2].power_to_complete = 600;
stage_[2].min_menace = 7 + (4 * 3); stage_[2].min_menace = 7 + (4 * 3);
stage_[2].max_menace = 7 + (4 * 5); stage_[2].max_menace = 7 + (4 * 5);
stage_[2].balloon_pool = &balloon_formation_pool_[2]; stage_[2].balloon_pool = balloon_formation_pool_[2];
// STAGE 4 // STAGE 4
stage_[3].number = 4; stage_[3].number = 4;
stage_[3].power_to_complete = 600; stage_[3].power_to_complete = 600;
stage_[3].min_menace = 7 + (4 * 3); stage_[3].min_menace = 7 + (4 * 3);
stage_[3].max_menace = 7 + (4 * 5); stage_[3].max_menace = 7 + (4 * 5);
stage_[3].balloon_pool = &balloon_formation_pool_[3]; stage_[3].balloon_pool = balloon_formation_pool_[3];
// STAGE 5 // STAGE 5
stage_[4].number = 5; stage_[4].number = 5;
stage_[4].power_to_complete = 600; stage_[4].power_to_complete = 600;
stage_[4].min_menace = 7 + (4 * 4); stage_[4].min_menace = 7 + (4 * 4);
stage_[4].max_menace = 7 + (4 * 6); stage_[4].max_menace = 7 + (4 * 6);
stage_[4].balloon_pool = &balloon_formation_pool_[4]; stage_[4].balloon_pool = balloon_formation_pool_[4];
// STAGE 6 // STAGE 6
stage_[5].number = 6; stage_[5].number = 6;
stage_[5].power_to_complete = 600; stage_[5].power_to_complete = 600;
stage_[5].min_menace = 7 + (4 * 4); stage_[5].min_menace = 7 + (4 * 4);
stage_[5].max_menace = 7 + (4 * 6); stage_[5].max_menace = 7 + (4 * 6);
stage_[5].balloon_pool = &balloon_formation_pool_[5]; stage_[5].balloon_pool = balloon_formation_pool_[5];
// STAGE 7 // STAGE 7
stage_[6].number = 7; stage_[6].number = 7;
stage_[6].power_to_complete = 650; stage_[6].power_to_complete = 650;
stage_[6].min_menace = 7 + (4 * 5); stage_[6].min_menace = 7 + (4 * 5);
stage_[6].max_menace = 7 + (4 * 7); stage_[6].max_menace = 7 + (4 * 7);
stage_[6].balloon_pool = &balloon_formation_pool_[6]; stage_[6].balloon_pool = balloon_formation_pool_[6];
// STAGE 8 // STAGE 8
stage_[7].number = 8; stage_[7].number = 8;
stage_[7].power_to_complete = 750; stage_[7].power_to_complete = 750;
stage_[7].min_menace = 7 + (4 * 5); stage_[7].min_menace = 7 + (4 * 5);
stage_[7].max_menace = 7 + (4 * 7); stage_[7].max_menace = 7 + (4 * 7);
stage_[7].balloon_pool = &balloon_formation_pool_[7]; stage_[7].balloon_pool = balloon_formation_pool_[7];
// STAGE 9 // STAGE 9
stage_[8].number = 9; stage_[8].number = 9;
stage_[8].power_to_complete = 850; stage_[8].power_to_complete = 850;
stage_[8].min_menace = 7 + (4 * 6); stage_[8].min_menace = 7 + (4 * 6);
stage_[8].max_menace = 7 + (4 * 8); stage_[8].max_menace = 7 + (4 * 8);
stage_[8].balloon_pool = &balloon_formation_pool_[8]; stage_[8].balloon_pool = balloon_formation_pool_[8];
// STAGE 10 // STAGE 10
stage_[9].number = 10; stage_[9].number = 10;
stage_[9].power_to_complete = 950; stage_[9].power_to_complete = 950;
stage_[9].min_menace = 7 + (4 * 7); stage_[9].min_menace = 7 + (4 * 7);
stage_[9].max_menace = 7 + (4 * 10); stage_[9].max_menace = 7 + (4 * 10);
stage_[9].balloon_pool = &balloon_formation_pool_[9]; stage_[9].balloon_pool = balloon_formation_pool_[9];
} }
// Devuelve una fase // Devuelve una fase

View File

@@ -1,40 +1,48 @@
#pragma once #pragma once
#include "balloon.h"
constexpr int NUMBER_OF_BALLOON_FORMATIONS = 100; constexpr int NUMBER_OF_BALLOON_FORMATIONS = 100;
constexpr int MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION = 50; 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 // Estructuras
struct BalloonFormationParams struct BalloonFormationParams
{ {
int x = 0; // Posición en el eje X donde crear al enemigo int x = 0; // Posición en el eje X donde crear el globo
int y = 0; // Posición en el eje Y donde crear al enemigo int y = 0; // Posición en el eje Y donde crear el globo
float vel_x = 0.0f; // Velocidad inicial en el eje X float vel_x = 0.0f; // Velocidad inicial en el eje X
int kind = 0; // Tipo de enemigo BalloonType type = BalloonType::BALLOON; // Tipo de globo
int creation_counter = 0; // Temporizador para la creación del enemigo BalloonSize size = BalloonSize::SIZE1; // Tamaño de globo
int creation_counter = 0; // Temporizador para la creación del globo
// Constructor que inicializa todos los campos con valores proporcionados o predeterminados // Constructor por defecto
explicit BalloonFormationParams(int x_val = 0, int y_val = 0, float vel_x_val = 0.0f, int kind_val = 0, int creation_counter_val = 0) BalloonFormationParams() = default;
: x(x_val), y(y_val), vel_x(vel_x_val), kind(kind_val), creation_counter(creation_counter_val) {}
// Constructor con parámetros
BalloonFormationParams(int x_val, int y_val, float vel_x_val, BalloonType type_val, BalloonSize size_val, int creation_counter_val)
: 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 // Contiene la información de una formación enemiga
{ {
int number_of_balloons; // Cantidad de enemigos que forman la formación 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 enemigos de la formación BalloonFormationParams init[MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION]; // Vector con todas las inicializaciones de los globos de la formación
}; };
struct BalloonFormationPool struct BalloonFormationPool
{ {
BalloonFormationUnit *set[10]; // Conjunto de formaciones de globos BalloonFormationUnit set[NUMBER_OF_SETS_PER_POOL]; // Conjunto de formaciones de globos
}; };
struct Stage // Contiene todas las variables relacionadas con una fase struct Stage // Contiene todas las variables relacionadas con una fase
{ {
BalloonFormationPool *balloon_pool; // El conjunto de formaciones de globos de la 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 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 max_menace; // Umbral máximo de amenaza de la fase
int min_menace; // Umbral mínimo de amenaza de la fase int min_menace; // Umbral mínimo de amenaza de la fase
int number; // Número de fase int number; // Número de fase
}; };
// Clase BalloonFormations, para gestionar las formaciones de globos // Clase BalloonFormations, para gestionar las formaciones de globos
@@ -42,9 +50,9 @@ class BalloonFormations
{ {
private: private:
// Variables // Variables
Stage stage_[10]; // Variable con los datos de cada pantalla 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 BalloonFormationUnit balloon_formation_[NUMBER_OF_BALLOON_FORMATIONS]; // Vector con todas las formaciones enemigas
BalloonFormationPool balloon_formation_pool_[10]; // Variable con los diferentes conjuntos de formaciones enemigas BalloonFormationPool balloon_formation_pool_[NUMBER_OF_STAGES]; // Variable con los diferentes conjuntos de formaciones enemigas
// Inicializa las formaciones enemigas // Inicializa las formaciones enemigas
void initBalloonFormations(); void initBalloonFormations();

View File

@@ -241,15 +241,16 @@ void Game::deployBalloonFormation()
last_balloon_deploy_ = set; last_balloon_deploy_ = set;
const Stage stage = balloon_formations_->getStage(current_stage_); const Stage stage = balloon_formations_->getStage(current_stage_);
const auto numEnemies = stage.balloon_pool->set[set]->number_of_balloons; const auto numEnemies = stage.balloon_pool.set[set].number_of_balloons;
for (int i = 0; i < numEnemies; ++i) for (int i = 0; i < numEnemies; ++i)
{ {
createBalloon(stage.balloon_pool->set[set]->init[i].x, createBalloon(stage.balloon_pool.set[set].init[i].x,
stage.balloon_pool->set[set]->init[i].y, stage.balloon_pool.set[set].init[i].y,
stage.balloon_pool->set[set]->init[i].kind, stage.balloon_pool.set[set].init[i].type,
stage.balloon_pool->set[set]->init[i].vel_x, stage.balloon_pool.set[set].init[i].size,
stage.balloon_pool.set[set].init[i].vel_x,
balloon_speed_, balloon_speed_,
stage.balloon_pool->set[set]->init[i].creation_counter); stage.balloon_pool.set[set].init[i].creation_counter);
} }
balloon_deploy_counter_ = 300; balloon_deploy_counter_ = 300;
@@ -432,10 +433,10 @@ void Game::renderBalloons()
} }
// Crea un globo nuevo en el vector de globos // Crea un globo nuevo en el vector de globos
std::shared_ptr<Balloon> Game::createBalloon(float x, int y, int kind, float velx, float speed, int creation_timer) std::shared_ptr<Balloon> Game::createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer)
{ {
const auto index = (kind - 1) % 4; const int index = static_cast<int>(size);
balloons_.emplace_back(std::make_shared<Balloon>(x, y, kind, velx, speed, creation_timer, balloon_textures_[index], balloon_animations_[index])); balloons_.emplace_back(std::make_shared<Balloon>(x, y, type, size, velx, speed, creation_timer, balloon_textures_.at(index), balloon_animations_.at(index)));
return balloons_.back(); return balloons_.back();
} }
@@ -443,21 +444,18 @@ std::shared_ptr<Balloon> Game::createBalloon(float x, int y, int kind, float vel
void Game::createPowerBall() void Game::createPowerBall()
{ {
constexpr auto values = 6; constexpr auto values = 6;
constexpr auto posY = -BLOCK; constexpr auto pos_y = -BLOCK;
constexpr int creation_time = 300;
const auto left = param.game.play_area.rect.x; const auto left = param.game.play_area.rect.x;
const auto center = param.game.play_area.center_x - (BALLOON_WIDTH_4 / 2); const auto center = param.game.play_area.center_x - (BALLOON_WIDTH_4 / 2);
const auto right = param.game.play_area.rect.w - BALLOON_WIDTH_4; const auto right = param.game.play_area.rect.w - BALLOON_WIDTH_4;
const auto vel_pos = BALLOON_VELX_POSITIVE;
const auto vel_neg = BALLOON_VELX_NEGATIVE;
const auto luck = rand() % values; const auto luck = rand() % values;
const int x[values] = {left, left, center, center, right, right}; const int x[values] = {left, left, center, center, right, right};
const float vx[values] = {vel_pos, vel_pos, vel_pos, vel_neg, vel_neg, vel_neg}; const float vx[values] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE};
auto b = std::make_unique<Balloon>(x[luck], posY, POWER_BALL, vx[luck], balloon_speed_, 300, balloon_textures_[4], balloon_animations_[4]); balloons_.emplace_back(std::make_unique<Balloon>(x[luck], pos_y, BalloonType::POWERBALL, BalloonSize::SIZE4, vx[luck], balloon_speed_, creation_time, balloon_textures_[4], balloon_animations_[4]));
balloons_.push_back(std::move(b));
power_ball_enabled_ = true; power_ball_enabled_ = true;
power_ball_counter_ = POWERBALL_COUNTER; power_ball_counter_ = POWERBALL_COUNTER;
@@ -516,8 +514,7 @@ void Game::popBalloon(std::shared_ptr<Balloon> balloon)
increaseStageCurrentPower(1); increaseStageCurrentPower(1);
balloons_popped_++; balloons_popped_++;
const auto kind = balloon->getKind(); if (balloon->getType() == BalloonType::POWERBALL)
if (kind == POWER_BALL)
{ {
destroyAllBalloons(); destroyAllBalloons();
power_ball_enabled_ = false; power_ball_enabled_ = false;
@@ -525,21 +522,24 @@ void Game::popBalloon(std::shared_ptr<Balloon> balloon)
} }
else else
{ {
const auto size = balloon->getSize(); const int size = static_cast<int>(balloon->getSize());
if (size == BALLOON_SIZE_1) if (size == static_cast<int>(BalloonSize::SIZE1))
{ // Si es del tipo más pequeño, simplemente elimina el globo {
// Si es del tipo más pequeño, simplemente elimina el globo
explosions_->add(balloon->getPosX(), balloon->getPosY(), size); explosions_->add(balloon->getPosX(), balloon->getPosY(), size);
balloon->pop(); balloon->pop();
} }
else else
{ // En cualquier otro caso, crea dos globos de un tipo inferior {
auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_NEGATIVE, balloon_speed_, 0); const auto lower_size = static_cast<BalloonSize>(size - 1);
// En cualquier otro caso, crea dos globos de un tipo inferior
auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, BALLOON_VELX_NEGATIVE, balloon_speed_, 0);
balloon_left->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); balloon_left->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
balloon_left->setVelY(balloon_left->getClass() == BALLOON_CLASS ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f); balloon_left->setVelY(balloon_left->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f);
auto balloon_right = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, BALLOON_VELX_POSITIVE, balloon_speed_, 0); auto balloon_right = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, BALLOON_VELX_POSITIVE, balloon_speed_, 0);
balloon_right->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); balloon_right->allignTo(balloon->getPosX() + (balloon->getWidth() / 2));
balloon_right->setVelY(balloon_right->getClass() == BALLOON_CLASS ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f); balloon_right->setVelY(balloon_right->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f);
// Elimina el globo // Elimina el globo
explosions_->add(balloon->getPosX(), balloon->getPosY(), size); explosions_->add(balloon->getPosX(), balloon->getPosY(), size);
@@ -554,42 +554,31 @@ void Game::popBalloon(std::shared_ptr<Balloon> balloon)
// Explosiona un globo. Lo destruye = no crea otros globos // Explosiona un globo. Lo destruye = no crea otros globos
void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon) void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon)
{ {
auto score = 0; int score = 0;
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos // Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
const auto size = balloon->getSize(); switch (balloon->getSize())
switch (size)
{
case BALLOON_SIZE_4:
{ {
case BalloonSize::SIZE4:
score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1); score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1);
break; break;
}
case BALLOON_SIZE_3: case BalloonSize::SIZE3:
{
score = BALLOON_SCORE_3 + (2 * BALLOON_SCORE_2) + (4 * BALLOON_SCORE_1); score = BALLOON_SCORE_3 + (2 * BALLOON_SCORE_2) + (4 * BALLOON_SCORE_1);
break; break;
}
case BALLOON_SIZE_2: case BalloonSize::SIZE2:
{
score = BALLOON_SCORE_2 + (2 * BALLOON_SCORE_1); score = BALLOON_SCORE_2 + (2 * BALLOON_SCORE_1);
break; break;
}
case BALLOON_SIZE_1: case BalloonSize::SIZE1:
{
score = BALLOON_SCORE_1; score = BALLOON_SCORE_1;
break; break;
}
default: default:
{
score = 0; score = 0;
break; break;
} }
}
// Otorga los puntos correspondientes al globo // Otorga los puntos correspondientes al globo
for (auto &player : players_) for (auto &player : players_)
@@ -604,7 +593,7 @@ void Game::destroyBalloon(std::shared_ptr<Balloon> &balloon)
balloons_popped_ += power; balloons_popped_ += power;
// Destruye el globo // Destruye el globo
explosions_->add(balloon->getPosX(), balloon->getPosY(), size); explosions_->add(balloon->getPosX(), balloon->getPosY(), static_cast<int>(balloon->getSize()));
balloon->pop(); balloon->pop();
// Recalcula el nivel de amenaza // Recalcula el nivel de amenaza
@@ -1705,17 +1694,12 @@ void Game::checkEvents()
// Crea dos BALLON4 // Crea dos BALLON4
case SDLK_2: case SDLK_2:
{ {
const auto set = 0; const auto set = balloon_formations_->getStage(0).balloon_pool.set[0];
const auto stage = balloon_formations_->getStage(0); const auto numEnemies = set.number_of_balloons;
const auto numEnemies = stage.balloon_pool->set[set]->number_of_balloons;
for (int i = 0; i < numEnemies; ++i) for (int i = 0; i < numEnemies; ++i)
{ {
createBalloon(stage.balloon_pool->set[set]->init[i].x, auto p = set.init[i];
stage.balloon_pool->set[set]->init[i].y, createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
stage.balloon_pool->set[set]->init[i].kind,
stage.balloon_pool->set[set]->init[i].vel_x,
balloon_speed_,
stage.balloon_pool->set[set]->init[i].creation_counter);
} }
} }
break; break;

View File

@@ -229,7 +229,7 @@ private:
void renderBalloons(); void renderBalloons();
// Crea un globo nuevo en el vector de globos // Crea un globo nuevo en el vector de globos
std::shared_ptr<Balloon> createBalloon(float x, int y, int kind, float velx, float speed, int stopped_counter); std::shared_ptr<Balloon> createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int stopped_counter);
// Crea una PowerBall // Crea una PowerBall
void createPowerBall(); void createPowerBall();