diff --git a/source/game.cpp b/source/game.cpp index e4d061d..66041c8 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2944,6 +2944,15 @@ bool Game::isDeathShaking() { // Ejecuta un frame del juego void Game::iterate() { + // En modo demo, no hay pausa ni game over + if (demo.enabled) { + if (section->subsection == SUBSECTION_GAME_PAUSE || section->subsection == SUBSECTION_GAME_GAMEOVER) { + section->name = SECTION_PROG_TITLE; + section->subsection = SUBSECTION_TITLE_INSTRUCTIONS; + return; + } + } + // Sección juego en pausa if (section->subsection == SUBSECTION_GAME_PAUSE) { if (!pauseInitialized) { @@ -3001,7 +3010,10 @@ void Game::handleEvent(SDL_Event *event) { // SDL_EVENT_QUIT ya lo maneja Director if (event->type == SDL_EVENT_WINDOW_FOCUS_LOST) { - section->subsection = SUBSECTION_GAME_PAUSE; + // Solo pausar durante el juego activo (no en demo, game over, ni ya en pausa) + if (!demo.enabled && (section->subsection == SUBSECTION_GAME_PLAY_1P || section->subsection == SUBSECTION_GAME_PLAY_2P)) { + section->subsection = SUBSECTION_GAME_PAUSE; + } } #ifdef PAUSE diff --git a/source/title.cpp b/source/title.cpp index 0b44e0c..59257e3 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -915,6 +915,8 @@ void Title::iterate() { // Si el juego demo está activo, delega el frame if (demoGameActive) { + // El demo Game necesita section->name == SECTION_PROG_GAME para funcionar + section->name = SECTION_PROG_GAME; demoGame->iterate(); if (demoGame->hasFinished()) { @@ -934,6 +936,9 @@ void Title::iterate() { section->name = SECTION_PROG_TITLE; section->subsection = SUBSECTION_TITLE_1; } + } else { + // Restaura section para que Director no transicione fuera de Title + section->name = SECTION_PROG_TITLE; } return; } @@ -987,11 +992,13 @@ void Title::runInstructions(mode_e mode) { // Inicia el juego en modo demo void Title::runDemoGame() { - // Guardamos el section actual para que Game pueda funcionar + // Temporalmente ponemos section para que el constructor de Game funcione section->name = SECTION_PROG_GAME; section->subsection = SUBSECTION_GAME_PLAY_1P; demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options, section); demoGameActive = true; + // Restauramos section para que Director no transicione fuera de Title + section->name = SECTION_PROG_TITLE; } // Modifica las opciones para los controles de los jugadores