Arreglada la cárrega d'animacions

This commit is contained in:
2024-10-24 19:58:25 +02:00
parent f26ecbd969
commit ca464b2e81
2 changed files with 60 additions and 43 deletions

View File

@@ -13,10 +13,17 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
pos_y_(y),
vel_x_(vel_x),
being_created_(creation_timer > 0),
blinking_(false),
enabled_(true),
invulnerable_(creation_timer > 0),
stopped_(true),
visible_(true),
creation_counter_(creation_timer),
creation_counter_ini_(creation_timer),
stopped_counter_(0),
kind_(kind),
counter_(0),
travel_y_(1.0f),
speed_(speed)
{
@@ -220,9 +227,23 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
break;
}
// Valores para el efecto de rebote
bouncing_.enabled = false;
bouncing_.counter = 0;
bouncing_.speed = 2;
bouncing_.zoomW = 1.0f;
bouncing_.zoomH = 1.0f;
bouncing_.despX = 0.0f;
bouncing_.despY = 0.0f;
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};
// 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;
// Alinea el circulo de colisión con el objeto
updateColliders();
}
@@ -705,8 +726,8 @@ Circle &Balloon::getCollider()
// Alinea el circulo de colisión con la posición del objeto globo
void Balloon::updateColliders()
{
collider_.x = static_cast<int>(pos_x_ + collider_.r);
collider_.y = static_cast<int>(pos_y_ + collider_.r);
collider_.x = Uint16(pos_x_ + collider_.r);
collider_.y = pos_y_ + collider_.r;
}
// Obtiene le valor de la variable