diff --git a/source/game.cpp b/source/game.cpp index 946c8d1..222312e 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -25,7 +25,6 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input) section.name = SECTION_PROG_GAME; section.subsection = SUBSECTION_GAME_PLAY; - musicEnabled = true; debug = true; musicEnabled = !debug; } @@ -45,9 +44,10 @@ Game::~Game() // Bucle para el juego section_t Game::run() { - if (musicEnabled) + JA_PlayMusic(music); + if (!musicEnabled) { - JA_PlayMusic(music); + JA_PauseMusic(); } while (section.name == SECTION_PROG_GAME) @@ -90,18 +90,16 @@ void Game::update() case SDL_SCANCODE_ESCAPE: section.name = SECTION_PROG_QUIT; break; - + case SDL_SCANCODE_D: debug = !debug; musicEnabled = !debug; - if (musicEnabled) - { - JA_PlayMusic(music); - } - else - { - JA_StopMusic(); - } + musicEnabled ? JA_ResumeMusic() : JA_PauseMusic(); + break; + + case SDL_SCANCODE_M: + musicEnabled = !musicEnabled; + musicEnabled ? JA_ResumeMusic() : JA_PauseMusic(); break; case SDL_SCANCODE_R: @@ -130,6 +128,9 @@ void Game::update() case SDL_SCANCODE_F4: screen->setWindowSize(4); break; + + default: + break; } } } @@ -184,7 +185,7 @@ void Game::renderDebugInfo() } // Pinta el texto - const int inc = debugText->getCharacterWidth() + 1; + const int inc = debugText->getCharacterWidth() + 1; int line = 0; std::string text = "";