diff --git a/source/game.cpp b/source/game.cpp index ac1c653..f71d4a4 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -151,7 +151,7 @@ void Game::update() } DEMO_checkRoomChange(); scoreboard_->update(); - + keepMusicPlaying(); updateBlackScreen(); Screen::get()->update(); @@ -698,4 +698,16 @@ void Game::DEMO_checkRoomChange() } } } +} + +// Hace sonar la música +void Game::keepMusicPlaying() +{ + const std::string music_path = mode_ == GameMode::GAME ? "game.ogg" : "title.ogg"; + + // Si la música no está sonando + if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED) + { + JA_PlayMusic(Resource::get()->getMusic(music_path)); + } } \ No newline at end of file diff --git a/source/game.h b/source/game.h index 5e438f3..941cce9 100644 --- a/source/game.h +++ b/source/game.h @@ -157,6 +157,9 @@ private: // DEMO MODE: Comprueba si se ha de cambiar de habitación void DEMO_checkRoomChange(); + // Hace sonar la música + void keepMusicPlaying(); + public: // Constructor Game(GameMode mode);