Fix: mil minibugs relacionats amb el audio

This commit is contained in:
2024-12-26 10:39:48 +01:00
parent ca18baefd7
commit 7f444fef33
2 changed files with 20 additions and 8 deletions

View File

@@ -69,6 +69,8 @@ Game::Game(int player_id, int current_stage, bool demo)
fade_in_->setType(FadeType::VENETIAN); fade_in_->setType(FadeType::VENETIAN);
fade_in_->setMode(FadeMode::IN); fade_in_->setMode(FadeMode::IN);
fade_in_->activate(); fade_in_->activate();
// JA_PlaySound(Resource::get()->getSound("fade_in.wav"));
// playMusic();
fade_out_->setColor(fade_color.r, fade_color.g, fade_color.b); fade_out_->setColor(fade_color.r, fade_color.g, fade_color.b);
fade_out_->setPost(param.fade.post_duration); fade_out_->setPost(param.fade.post_duration);
@@ -98,9 +100,9 @@ Game::Game(int player_id, int current_stage, bool demo)
Game::~Game() Game::~Game()
{ {
// Guarda las puntuaciones en un fichero
if (!demo_.enabled) if (!demo_.enabled)
{ {
// Guarda las puntuaciones en un fichero
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table); auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
manager->saveToFile(asset_->get("score.bin")); manager->saveToFile(asset_->get("score.bin"));
} }
@@ -109,6 +111,7 @@ Game::~Game()
// Habilita los sonidos // Habilita los sonidos
JA_EnableSound(true); JA_EnableSound(true);
} }
#ifdef RECORDING #ifdef RECORDING
saveDemoFile(Asset::get()->get("demo1.bin"), demo_.data.at(0)); saveDemoFile(Asset::get()->get("demo1.bin"), demo_.data.at(0));
#endif #endif
@@ -294,6 +297,7 @@ void Game::updateFadeInState()
balloon_manager_->createTwoBigBalloons(); balloon_manager_->createTwoBigBalloons();
evaluateAndSetMenace(); evaluateAndSetMenace();
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("get_ready")); createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("get_ready"));
JA_PlaySound(Resource::get()->getSound("stage_change.wav"));
} }
} }
} }
@@ -309,7 +313,8 @@ void Game::updateGameOverState()
if (game_over_counter_ == GAME_OVER_COUNTER_) if (game_over_counter_ == GAME_OVER_COUNTER_)
{ {
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_over")); createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_over"));
stopMusic(); // stopMusic();
JA_FadeOutMusic(1000);
balloon_manager_->setSounds(true); balloon_manager_->setSounds(true);
} }
@@ -986,7 +991,11 @@ void Game::disableTimeStopItem()
void Game::checkMusicStatus() void Game::checkMusicStatus()
{ {
// Si se ha completado el juego o los jugadores han terminado, detiene la música // Si se ha completado el juego o los jugadores han terminado, detiene la música
state_ == GameState::FADE_IN || state_ == GameState::COMPLETED || allPlayersAreGameOver() ? stopMusic() : playMusic(); // state_ == GameState::FADE_IN || state_ == GameState::COMPLETED || allPlayersAreGameOver() ? stopMusic() : playMusic();
if (state_ != GameState::COMPLETED && !allPlayersAreGameOver())
{
playMusic();
}
} }
// Bucle para el juego // Bucle para el juego

View File

@@ -257,11 +257,14 @@ void Title::checkInput()
{ {
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP) if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
{ {
fade_->activate(); if (!fade_->isEnabled())
JA_FadeOutMusic(1500); {
JA_PlaySound(Resource::get()->getSound("game_start.wav")); JA_PlaySound(Resource::get()->getSound("game_start.wav"));
post_fade_ = controller.player_id; JA_FadeOutMusic(1500);
return; fade_->activate();
post_fade_ = controller.player_id;
return;
}
} }
} }