fix: els globos tenien un parell de setters mal asignats per culpa de buscar y reemplazar

fix: els globos verds s'inicialitzaven amb vy = 0 per gastar abs en lloc de fabs
fix: corregit un bug milenari que de sempre havia creat els balloons verds al popar al pare amb la meitat de velocitat en y. Lo que jo no se es com anava res. Supose que ara el joc serà un poc mes xungo. Quan rebotaven en el piso ja se'ls posava la velocitat bona (crec)
This commit is contained in:
2024-10-20 22:58:15 +02:00
parent a3a583deb7
commit 2cb22ed013
5 changed files with 69 additions and 110 deletions

View File

@@ -121,10 +121,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
power_ = 1;
// Inicializa los valores de velocidad y gravedad
vel_y_ = abs(vel_x) * 2;
max_vel_y_ = abs(vel_x) * 2;
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = abs(vel_x) * 2;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_1;
@@ -142,10 +142,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
power_ = 3;
// Inicializa los valores de velocidad y gravedad
vel_y_ = abs(vel_x) * 2;
max_vel_y_ = abs(vel_x) * 2;
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = abs(vel_x) * 2;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_2;
@@ -163,10 +163,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
power_ = 7;
// Inicializa los valores de velocidad y gravedad
vel_y_ = abs(vel_x) * 2;
max_vel_y_ = abs(vel_x) * 2;
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = abs(vel_x) * 2;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
score_ = BALLOON_SCORE_3;
@@ -184,10 +184,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
power_ = 15;
// Inicializa los valores de velocidad y gravedad
vel_y_ = abs(vel_x) * 2;
max_vel_y_ = abs(vel_x) * 2;
vel_y_ = fabs(vel_x_ * 2.0f);
max_vel_y_ = vel_y_;
gravity_ = 0.00f;
default_vel_y_ = abs(vel_x) * 2;
default_vel_y_ = vel_y_;
// Puntos que da el globo al ser destruido
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_.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_
sprite_->setWidth(width_);
sprite_->setHeight(height_);
// Posición X,Y del sprite_
sprite_->setPosX((int)pos_x_);
sprite_->setPosY((int)pos_y_);
// Configura el sprite
sprite_->setPos({static_cast<int>(pos_x_), static_cast<int>(pos_y_), width_, height_});
// Tamaño del circulo de colisión
collider_.r = width_ / 2;
@@ -396,10 +391,6 @@ void Balloon::move()
// Aplica la gravedad al objeto sin pasarse de una velocidad máxima
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_
@@ -460,7 +451,7 @@ void Balloon::update()
updateColliders();
updateState();
updateBounce();
counter_++;
++counter_;
}
}
@@ -609,15 +600,15 @@ int Balloon::getHeight() const
}
// 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
void Balloon::setSpeed(float speed_)
void Balloon::setSpeed(float speed)
{
this->speed_ = speed_;
speed_ = speed;
}
// Obtiene del valor de la variable