2025-07-24 14:02:51 +02:00
9 changed files with 29 additions and 25 deletions

View File

@@ -32,10 +32,6 @@ class Balloon {
static constexpr float VELX_POSITIVE = 0.7F;
static constexpr float VELX_NEGATIVE = -0.7F;
static constexpr int MOVING_ANIMATION = 0;
static constexpr int POP_ANIMATION = 1;
static constexpr int BORN_ANIMATION = 2;
static constexpr std::array<float, 5> SPEED = {0.60F, 0.70F, 0.80F, 0.90F, 1.00F};
static constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;

View File

@@ -22,6 +22,12 @@ BalloonManager::BalloonManager()
// Inicializa
void BalloonManager::init() {
// Limpia
balloon_textures_.clear();
balloon_animations_.clear();
explosions_textures_.clear();
explosions_animations_.clear();
// Texturas - Globos
balloon_textures_.emplace_back(Resource::get()->getTexture("balloon0.png"));
balloon_textures_.emplace_back(Resource::get()->getTexture("balloon1.png"));
@@ -49,10 +55,10 @@ void BalloonManager::init() {
explosions_animations_.emplace_back(Resource::get()->getAnimation("explosion3.ani"));
// Añade texturas
explosions_->addTexture(0, explosions_textures_[0], explosions_animations_[0]);
explosions_->addTexture(1, explosions_textures_[1], explosions_animations_[1]);
explosions_->addTexture(2, explosions_textures_[2], explosions_animations_[2]);
explosions_->addTexture(3, explosions_textures_[3], explosions_animations_[3]);
explosions_->addTexture(0, explosions_textures_.at(0), explosions_animations_.at(0));
explosions_->addTexture(1, explosions_textures_.at(1), explosions_animations_.at(1));
explosions_->addTexture(2, explosions_textures_.at(2), explosions_animations_.at(2));
explosions_->addTexture(3, explosions_textures_.at(3), explosions_animations_.at(3));
}
// Actualiza
@@ -121,8 +127,8 @@ void BalloonManager::deploySet(int set_number) {
const auto SET = balloon_formations_->getSet(set_number);
const auto NUM_ENEMIES = SET.number_of_balloons;
for (int i = 0; i < NUM_ENEMIES; ++i) {
auto p = SET.init[i];
createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
auto balloon = SET.init[i];
createBalloon(balloon.x, balloon.y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
}
}
@@ -131,8 +137,8 @@ void BalloonManager::deploySet(int set_number, int y) {
const auto SET = balloon_formations_->getSet(set_number);
const auto NUM_ENEMIES = SET.number_of_balloons;
for (int i = 0; i < NUM_ENEMIES; ++i) {
auto p = SET.init[i];
createBalloon(p.x, y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter);
auto balloon = SET.init[i];
createBalloon(balloon.x, y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
}
}

View File

@@ -1,7 +1,7 @@
// IWYU pragma: no_include <bits/std_abs.h>
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <bits/std_abs.h> // Para abs
#include <algorithm> // Para max, min
#include <array> // Para array

View File

@@ -1768,9 +1768,11 @@ void Game::checkAndUpdateBalloonSpeed() {
constexpr std::array<float, 4> THRESHOLDS = {0.2F, 0.4F, 0.6F, 0.8F};
for (size_t i = 0; i < std::size(THRESHOLDS); ++i) {
if (balloon_manager_->getBalloonSpeed() == Balloon::SPEED.at(i) && PERCENT > THRESHOLDS[i]) {
// Si la velocidad actual del globo es la correspondiente al umbral "i" y el porcentaje de progreso ha superado ese umbral
if (balloon_manager_->getBalloonSpeed() == Balloon::SPEED.at(i) && PERCENT > THRESHOLDS.at(i)) {
// Sube la velocidad al siguiente nivel (i + 1)
balloon_manager_->setBalloonSpeed(Balloon::SPEED.at(i + 1));
break; // Salir del bucle una vez actualizada la velocidad y aplicada
return;
}
}
}