From fe950e6f174c41bcf3b00fbe21ac5472a7f1560a Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 24 Aug 2025 14:57:08 +0200 Subject: [PATCH] bug fix: en el modo demo la powerball feia ruido. Resol #84 --- source/balloon_manager.cpp | 3 +++ source/sections/game.cpp | 41 ++++++++++++++------------------------ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/source/balloon_manager.cpp b/source/balloon_manager.cpp index 58de61f..2ab8f26 100644 --- a/source/balloon_manager.cpp +++ b/source/balloon_manager.cpp @@ -209,6 +209,9 @@ void BalloonManager::createPowerBall() { balloons_.emplace_back(std::make_unique(POS_X[LUCK], POS_Y, Balloon::Type::POWERBALL, Balloon::Size::EXTRALARGE, VEL_X[LUCK], balloon_speed_, CREATION_TIME, play_area_, balloon_textures_[4], balloon_animations_[4])); balloons_.back()->setInvulnerable(true); + balloons_.back()->setSound(sound_enabled_); + balloons_.back()->setBouncingSound(bouncing_sound_enabled_); + balloons_.back()->setPoppingSound(poping_sound_enabled_); power_ball_enabled_ = true; power_ball_counter_ = Balloon::POWERBALL_COUNTER; diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 07a05dc..baaa78f 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -1463,20 +1463,16 @@ void Game::initDemo(Player::Id player_id) { setState(State::PLAYING); // Aleatoriza la asignación del fichero con los datos del modo demostracion - { - const auto DEMO1 = rand() % 2; - const auto DEMO2 = (DEMO1 == 0) ? 1 : 0; - demo_.data.emplace_back(Resource::get()->getDemoData(DEMO1)); - demo_.data.emplace_back(Resource::get()->getDemoData(DEMO2)); - } + const auto DEMO1 = rand() % 2; + const auto DEMO2 = (DEMO1 == 0) ? 1 : 0; + demo_.data.emplace_back(Resource::get()->getDemoData(DEMO1)); + demo_.data.emplace_back(Resource::get()->getDemoData(DEMO2)); // Selecciona una pantalla al azar - { - constexpr auto NUM_DEMOS = 3; - const auto DEMO = rand() % NUM_DEMOS; - constexpr std::array STAGES = {0, 3, 5}; - stage_manager_->jumpToStage(STAGES.at(DEMO)); - } + constexpr auto NUM_DEMOS = 3; + const auto DEMO = rand() % NUM_DEMOS; + constexpr std::array STAGES = {0, 3, 5}; + stage_manager_->jumpToStage(STAGES.at(DEMO)); // Activa o no al otro jugador if (rand() % 3 != 0) { @@ -1879,20 +1875,17 @@ void Game::handleDebugEvents(const SDL_Event &event) { static int formation_id_ = 0; if (event.type == SDL_EVENT_KEY_DOWN && static_cast(event.key.repeat) == 0) { switch (event.key.key) { - case SDLK_1: // Crea una powerball - { + case SDLK_1: { // Crea una powerball balloon_manager_->createPowerBall(); break; } - case SDLK_2: // Activa o desactiva la aparición de globos - { + case SDLK_2: { // Activa o desactiva la aparición de globos static bool deploy_balloons_ = true; deploy_balloons_ = !deploy_balloons_; balloon_manager_->enableBalloonDeployment(deploy_balloons_); break; } - case SDLK_3: // Activa el modo para pasar el juego automaticamente - { + case SDLK_3: { // Activa el modo para pasar el juego automaticamente auto_pop_balloons_ = !auto_pop_balloons_; Notifier::get()->show({"auto advance: " + boolToString(auto_pop_balloons_)}); if (auto_pop_balloons_) { @@ -1902,24 +1895,20 @@ void Game::handleDebugEvents(const SDL_Event &event) { balloon_manager_->enableBalloonDeployment(!auto_pop_balloons_); break; } - case SDLK_4: // Suelta un item - { + case SDLK_4: { // Suelta un item createItem(ItemType::CLOCK, players_.at(0)->getPosX(), players_.at(0)->getPosY() - 40); break; } - case SDLK_5: // 5.000 - { + case SDLK_5: { // 5.000 const int X = players_.at(0)->getPosX() + ((Player::WIDTH - game_text_textures_[3]->getWidth()) / 2); createItemText(X, game_text_textures_.at(2)); break; } - case SDLK_6: // Crea un mensaje - { + case SDLK_6: { // Crea un mensaje createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready")); break; } - case SDLK_7: // 100.000 - { + case SDLK_7: { // 100.000 const int X = players_.at(0)->getPosX() + ((Player::WIDTH - game_text_textures_[3]->getWidth()) / 2); createItemText(X, game_text_textures_.at(6)); break;