Compare commits
1 Commits
a3a583deb7
...
2024-10-20
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cb22ed013 |
@@ -121,10 +121,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
power_ = 1;
|
power_ = 1;
|
||||||
|
|
||||||
// Inicializa los valores de velocidad y gravedad
|
// Inicializa los valores de velocidad y gravedad
|
||||||
vel_y_ = abs(vel_x) * 2;
|
vel_y_ = fabs(vel_x_ * 2.0f);
|
||||||
max_vel_y_ = abs(vel_x) * 2;
|
max_vel_y_ = vel_y_;
|
||||||
gravity_ = 0.00f;
|
gravity_ = 0.00f;
|
||||||
default_vel_y_ = abs(vel_x) * 2;
|
default_vel_y_ = vel_y_;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score_ = BALLOON_SCORE_1;
|
score_ = BALLOON_SCORE_1;
|
||||||
@@ -142,10 +142,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
power_ = 3;
|
power_ = 3;
|
||||||
|
|
||||||
// Inicializa los valores de velocidad y gravedad
|
// Inicializa los valores de velocidad y gravedad
|
||||||
vel_y_ = abs(vel_x) * 2;
|
vel_y_ = fabs(vel_x_ * 2.0f);
|
||||||
max_vel_y_ = abs(vel_x) * 2;
|
max_vel_y_ = vel_y_;
|
||||||
gravity_ = 0.00f;
|
gravity_ = 0.00f;
|
||||||
default_vel_y_ = abs(vel_x) * 2;
|
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_2;
|
||||||
@@ -163,10 +163,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
power_ = 7;
|
power_ = 7;
|
||||||
|
|
||||||
// Inicializa los valores de velocidad y gravedad
|
// Inicializa los valores de velocidad y gravedad
|
||||||
vel_y_ = abs(vel_x) * 2;
|
vel_y_ = fabs(vel_x_ * 2.0f);
|
||||||
max_vel_y_ = abs(vel_x) * 2;
|
max_vel_y_ = vel_y_;
|
||||||
gravity_ = 0.00f;
|
gravity_ = 0.00f;
|
||||||
default_vel_y_ = abs(vel_x) * 2;
|
default_vel_y_ = vel_y_;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score_ = BALLOON_SCORE_3;
|
score_ = BALLOON_SCORE_3;
|
||||||
@@ -184,10 +184,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
power_ = 15;
|
power_ = 15;
|
||||||
|
|
||||||
// Inicializa los valores de velocidad y gravedad
|
// Inicializa los valores de velocidad y gravedad
|
||||||
vel_y_ = abs(vel_x) * 2;
|
vel_y_ = fabs(vel_x_ * 2.0f);
|
||||||
max_vel_y_ = abs(vel_x) * 2;
|
max_vel_y_ = vel_y_;
|
||||||
gravity_ = 0.00f;
|
gravity_ = 0.00f;
|
||||||
default_vel_y_ = abs(vel_x) * 2;
|
default_vel_y_ = vel_y_;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score_ = BALLOON_SCORE_4;
|
score_ = BALLOON_SCORE_4;
|
||||||
@@ -238,13 +238,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
bouncing_.w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f};
|
bouncing_.w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f};
|
||||||
bouncing_.h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f};
|
bouncing_.h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f};
|
||||||
|
|
||||||
// Alto y ancho del sprite_
|
// Configura el sprite
|
||||||
sprite_->setWidth(width_);
|
sprite_->setPos({static_cast<int>(pos_x_), static_cast<int>(pos_y_), width_, height_});
|
||||||
sprite_->setHeight(height_);
|
|
||||||
|
|
||||||
// Posición X,Y del sprite_
|
|
||||||
sprite_->setPosX((int)pos_x_);
|
|
||||||
sprite_->setPosY((int)pos_y_);
|
|
||||||
|
|
||||||
// Tamaño del circulo de colisión
|
// Tamaño del circulo de colisión
|
||||||
collider_.r = width_ / 2;
|
collider_.r = width_ / 2;
|
||||||
@@ -396,10 +391,6 @@ void Balloon::move()
|
|||||||
|
|
||||||
// Aplica la gravedad al objeto sin pasarse de una velocidad máxima
|
// Aplica la gravedad al objeto sin pasarse de una velocidad máxima
|
||||||
vel_y_ += gravity_;
|
vel_y_ += gravity_;
|
||||||
|
|
||||||
// Al parecer esta asignación se quedó sin hacer y ahora el juego no funciona
|
|
||||||
// correctamente si se aplica, así que se deja sin efecto
|
|
||||||
// vel_y_ = std::min(vel_y_, max_vel_y_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la posición del sprite_
|
// Actualiza la posición del sprite_
|
||||||
@@ -460,7 +451,7 @@ void Balloon::update()
|
|||||||
updateColliders();
|
updateColliders();
|
||||||
updateState();
|
updateState();
|
||||||
updateBounce();
|
updateBounce();
|
||||||
counter_++;
|
++counter_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,15 +600,15 @@ int Balloon::getHeight() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Balloon::setVelY(float vel_y_)
|
void Balloon::setVelY(float vel_y)
|
||||||
{
|
{
|
||||||
this->vel_y_ = vel_y_;
|
vel_y_ = vel_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Balloon::setSpeed(float speed_)
|
void Balloon::setSpeed(float speed)
|
||||||
{
|
{
|
||||||
this->speed_ = speed_;
|
speed_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene del valor de la variable
|
// Obtiene del valor de la variable
|
||||||
|
|||||||
@@ -37,15 +37,11 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
balloon_formation_[i].number_of_balloons = 0;
|
balloon_formation_[i].number_of_balloons = 0;
|
||||||
for (int j = 0; j < MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION; j++)
|
for (int j = 0; j < MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION; j++)
|
||||||
{
|
{
|
||||||
balloon_formation_[i].init[j].x = 0;
|
balloon_formation_[i].init[j] = BalloonFormationParams();
|
||||||
balloon_formation_[i].init[j].y = 0;
|
|
||||||
balloon_formation_[i].init[j].vel_x = 0;
|
|
||||||
balloon_formation_[i].init[j].kind = 0;
|
|
||||||
balloon_formation_[i].init[j].creation_counter = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int creation_time = 300;
|
constexpr int CREATION_TIME = 300;
|
||||||
int inc_x = 0;
|
int inc_x = 0;
|
||||||
int inc_time = 0;
|
int inc_time = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@@ -61,7 +57,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_4;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time + (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
||||||
@@ -75,7 +71,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_4;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time + (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
|
// #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
|
||||||
@@ -89,7 +85,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_2;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
|
// #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
|
||||||
@@ -103,7 +99,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_2;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha
|
// #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha
|
||||||
@@ -117,7 +113,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda
|
// #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda
|
||||||
@@ -131,7 +127,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha
|
// #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha
|
||||||
@@ -145,7 +141,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda
|
// #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda
|
||||||
@@ -159,7 +155,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha
|
// #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha
|
||||||
@@ -173,7 +169,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_1;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda
|
// #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda
|
||||||
@@ -187,7 +183,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_1;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #10 - Tres enemigos BALLOON4 seguidos desde la izquierda
|
// #10 - Tres enemigos BALLOON4 seguidos desde la izquierda
|
||||||
@@ -201,7 +197,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_4;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #11 - Tres enemigos BALLOON4 seguidos desde la derecha
|
// #11 - Tres enemigos BALLOON4 seguidos desde la derecha
|
||||||
@@ -215,7 +211,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_4;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
|
// #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro
|
||||||
@@ -229,7 +225,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_2;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
|
// #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro
|
||||||
@@ -243,7 +239,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_2;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados
|
// #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados
|
||||||
@@ -257,7 +253,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados
|
// #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados
|
||||||
@@ -271,7 +267,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos
|
// #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos
|
||||||
@@ -285,7 +281,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos
|
// #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos
|
||||||
@@ -299,7 +295,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_3;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos
|
// #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos
|
||||||
@@ -313,7 +309,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_1;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos
|
// #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos
|
||||||
@@ -327,7 +323,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
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].kind = BALLOON_1;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos
|
// #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos
|
||||||
@@ -350,7 +346,7 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
}
|
}
|
||||||
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].kind = BALLOON_4;
|
||||||
balloon_formation_[j].init[i].creation_counter = creation_time + (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos
|
// #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos
|
||||||
@@ -365,13 +361,13 @@ 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].vel_x = BALLOON_VELX_POSITIVE;
|
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
|
||||||
balloon_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x2_100 - ((i - half) * inc_x);
|
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].vel_x = BALLOON_VELX_NEGATIVE;
|
||||||
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].kind = BALLOON_2;
|
||||||
@@ -389,13 +385,13 @@ 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].vel_x = BALLOON_VELX_POSITIVE;
|
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
|
||||||
balloon_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x);
|
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].vel_x = BALLOON_VELX_NEGATIVE;
|
||||||
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].kind = BALLOON_3;
|
||||||
@@ -413,13 +409,13 @@ 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].vel_x = BALLOON_VELX_POSITIVE;
|
balloon_formation_[j].init[i].vel_x = BALLOON_VELX_POSITIVE;
|
||||||
balloon_formation_[j].init[i].creation_counter = (creation_time) - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x3_100 - ((i - half) * inc_x);
|
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].vel_x = BALLOON_VELX_NEGATIVE;
|
||||||
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].kind = BALLOON_3;
|
||||||
@@ -436,13 +432,13 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x1_50;
|
balloon_formation_[j].init[i].x = x1_50;
|
||||||
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].creation_counter = (creation_time) + (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x1_50;
|
balloon_formation_[j].init[i].x = x1_50;
|
||||||
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].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].kind = BALLOON_1;
|
||||||
@@ -459,13 +455,13 @@ void BalloonFormations::initBalloonFormations()
|
|||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x1_50 + 20;
|
balloon_formation_[j].init[i].x = x1_50 + 20;
|
||||||
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].creation_counter = (creation_time) - (inc_time * i);
|
balloon_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
balloon_formation_[j].init[i].x = x1_50 - 20;
|
balloon_formation_[j].init[i].x = x1_50 - 20;
|
||||||
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].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].kind = BALLOON_1;
|
||||||
|
|||||||
@@ -6,11 +6,15 @@ constexpr int MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION = 50;
|
|||||||
// Estructuras
|
// Estructuras
|
||||||
struct BalloonFormationParams
|
struct BalloonFormationParams
|
||||||
{
|
{
|
||||||
int x; // Posición en el eje X donde crear al enemigo
|
int x = 0; // Posición en el eje X donde crear al enemigo
|
||||||
int y; // Posición en el eje Y donde crear al enemigo
|
int y = 0; // Posición en el eje Y donde crear al enemigo
|
||||||
float vel_x; // Velocidad inicial en el eje X
|
float vel_x = 0.0f; // Velocidad inicial en el eje X
|
||||||
int kind; // Tipo de enemigo
|
int kind = 0; // Tipo de enemigo
|
||||||
int creation_counter; // Temporizador para la creación del enemigo
|
int creation_counter = 0; // Temporizador para la creación del enemigo
|
||||||
|
|
||||||
|
// Constructor que inicializa todos los campos con valores proporcionados o predeterminados
|
||||||
|
BalloonFormationParams(int x_val = 0, int y_val = 0, float vel_x_val = 0.0f, int kind_val = 0, int creation_counter_val = 0)
|
||||||
|
: x(x_val), y(y_val), vel_x(vel_x_val), kind(kind_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
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "texture.h" // for Texture
|
#include "texture.h" // for Texture
|
||||||
struct JA_Music_t; // lines 35-35
|
struct JA_Music_t; // lines 35-35
|
||||||
struct JA_Sound_t; // lines 36-36
|
struct JA_Sound_t; // lines 36-36
|
||||||
|
#include "dbgtxt.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(int player_id, int current_stage, bool demo)
|
Game::Game(int player_id, int current_stage, bool demo)
|
||||||
@@ -438,7 +439,7 @@ void Game::deployBalloonFormation()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Decrementa el contador de despliegues enemigos de la PowerBall
|
// Decrementa el contador de despliegues enemigos de la PowerBall
|
||||||
power_ball_counter_ > 0 ? power_ball_counter_-- : power_ball_counter_ = 0;
|
power_ball_counter_ = (power_ball_counter_ > 0) ? (power_ball_counter_ - 1) : 0;
|
||||||
|
|
||||||
// Elige una formación enemiga la azar
|
// Elige una formación enemiga la azar
|
||||||
auto set = rand() % 10;
|
auto set = rand() % 10;
|
||||||
@@ -646,9 +647,8 @@ void Game::renderBalloons()
|
|||||||
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, int kind, float velx, float speed, int creation_timer)
|
||||||
{
|
{
|
||||||
const auto index = (kind - 1) % 4;
|
const auto index = (kind - 1) % 4;
|
||||||
auto b = 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, kind, velx, speed, creation_timer, balloon_textures_[index], balloon_animations_[index]));
|
||||||
balloons_.push_back(b);
|
return balloons_.back();
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea una PowerBall
|
// Crea una PowerBall
|
||||||
@@ -747,11 +747,11 @@ void Game::popBalloon(std::shared_ptr<Balloon> balloon)
|
|||||||
{ // En cualquier otro caso, crea dos globos de un tipo inferior
|
{ // 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);
|
auto balloon_left = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, 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);
|
balloon_left->setVelY(balloon_left->getClass() == BALLOON_CLASS ? -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->getKind() - 1, 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);
|
balloon_right->setVelY(balloon_right->getClass() == BALLOON_CLASS ? -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);
|
||||||
|
|||||||
@@ -210,45 +210,16 @@ DemoData loadDemoDataFromFile(const std::string &file_path)
|
|||||||
DemoData dd;
|
DemoData dd;
|
||||||
|
|
||||||
// Indicador de éxito en la carga
|
// Indicador de éxito en la carga
|
||||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
|
||||||
auto file = SDL_RWFromFile(file_path.c_str(), "r+b");
|
auto file = SDL_RWFromFile(file_path.c_str(), "r+b");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Fichero no encontrado " << file_path << std::endl;
|
std::cerr << "Error: Fichero no encontrado " << file_path << std::endl;
|
||||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||||
}
|
}
|
||||||
/*{ // El fichero no existe
|
|
||||||
std::cout << "Warning: Unable to open " << file_name.c_str() << " file" << std::endl;
|
|
||||||
|
|
||||||
// Creamos el fichero para escritura
|
|
||||||
file = SDL_RWFromFile(file_path.c_str(), "w+b");
|
|
||||||
|
|
||||||
// Si ha creado el fichero
|
|
||||||
if (file)
|
|
||||||
{
|
|
||||||
std::cout << "New file (" << file_name.c_str() << ") created!" << std::endl;
|
|
||||||
|
|
||||||
// Inicializas los datos y los guarda en el fichero
|
|
||||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
|
||||||
{
|
|
||||||
DemoKeys dk = DemoKeys();
|
|
||||||
dd.push_back(dk);
|
|
||||||
SDL_RWwrite(file, &dk, sizeof(DemoKeys), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cerramos el fichero
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Si no puede crear el fichero
|
|
||||||
std::cout << "Error: Unable to create file " << file_name.c_str() << std::endl;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
// El fichero existe
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mensaje de proceder a la carga de los datos
|
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||||
// std::cout << "Reading file: " << file_name.c_str() << std::endl;
|
printWithDots("DemoData : ", file_name, "[ LOADED ]");
|
||||||
|
|
||||||
// Lee todos los datos del fichero y los deja en el destino
|
// Lee todos los datos del fichero y los deja en el destino
|
||||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
|
||||||
@@ -260,9 +231,6 @@ DemoData loadDemoDataFromFile(const std::string &file_path)
|
|||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
|
|
||||||
// Mensaje de datos cargados a la carga de los datos
|
|
||||||
printWithDots("DemoData : ", file_name, "[ LOADED ]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dd;
|
return dd;
|
||||||
|
|||||||
Reference in New Issue
Block a user