corregits bugs dels sub-bucles aplanats
- Demo ja no entra en pausa ni game over (redirigeix a instruccions) - Perdre el focus de la finestra només pausa durant el joc actiu (no en demo, game over ni pausa) - Demo gestionat amb save/restore de section->name per evitar transició del Director Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2944,6 +2944,15 @@ bool Game::isDeathShaking() {
|
|||||||
|
|
||||||
// Ejecuta un frame del juego
|
// Ejecuta un frame del juego
|
||||||
void Game::iterate() {
|
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
|
// Sección juego en pausa
|
||||||
if (section->subsection == SUBSECTION_GAME_PAUSE) {
|
if (section->subsection == SUBSECTION_GAME_PAUSE) {
|
||||||
if (!pauseInitialized) {
|
if (!pauseInitialized) {
|
||||||
@@ -3001,7 +3010,10 @@ void Game::handleEvent(SDL_Event *event) {
|
|||||||
// SDL_EVENT_QUIT ya lo maneja Director
|
// SDL_EVENT_QUIT ya lo maneja Director
|
||||||
|
|
||||||
if (event->type == SDL_EVENT_WINDOW_FOCUS_LOST) {
|
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
|
#ifdef PAUSE
|
||||||
|
|||||||
@@ -915,6 +915,8 @@ void Title::iterate() {
|
|||||||
|
|
||||||
// Si el juego demo está activo, delega el frame
|
// Si el juego demo está activo, delega el frame
|
||||||
if (demoGameActive) {
|
if (demoGameActive) {
|
||||||
|
// El demo Game necesita section->name == SECTION_PROG_GAME para funcionar
|
||||||
|
section->name = SECTION_PROG_GAME;
|
||||||
demoGame->iterate();
|
demoGame->iterate();
|
||||||
|
|
||||||
if (demoGame->hasFinished()) {
|
if (demoGame->hasFinished()) {
|
||||||
@@ -934,6 +936,9 @@ void Title::iterate() {
|
|||||||
section->name = SECTION_PROG_TITLE;
|
section->name = SECTION_PROG_TITLE;
|
||||||
section->subsection = SUBSECTION_TITLE_1;
|
section->subsection = SUBSECTION_TITLE_1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Restaura section para que Director no transicione fuera de Title
|
||||||
|
section->name = SECTION_PROG_TITLE;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -987,11 +992,13 @@ void Title::runInstructions(mode_e mode) {
|
|||||||
|
|
||||||
// Inicia el juego en modo demo
|
// Inicia el juego en modo demo
|
||||||
void Title::runDemoGame() {
|
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->name = SECTION_PROG_GAME;
|
||||||
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
||||||
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options, section);
|
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options, section);
|
||||||
demoGameActive = true;
|
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
|
// Modifica las opciones para los controles de los jugadores
|
||||||
|
|||||||
Reference in New Issue
Block a user