From 112c3afc76e509de4633e19f5ce451a6e3683713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Fri, 14 Oct 2022 09:52:15 +0200 Subject: [PATCH] Solucionado el problema de no cerrar el juego durante la demo o las instrucciones --- .gitignore | 6 +++--- data/config/score.bin | Bin 12 -> 12 bytes source/instructions.cpp | 4 +++- source/instructions.h | 2 +- source/title.cpp | 22 ++++++++++++++++------ source/title.h | 4 ++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index b484c47..386b4d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .vscode *.DS_Store bin -data/config.txt -data/config.bin -data/score.bin \ No newline at end of file +data/config/config.txt +data/config/config.bin +data/config/score.bin \ No newline at end of file diff --git a/data/config/score.bin b/data/config/score.bin index faf01e43024c8eafce491ab5969d9915b23ff148..47c2e0da0fc3f77480a5f18710dd6b5ed1f8370d 100644 GIT binary patch literal 12 Ocmeye$&5jW0RjLO&H?WL literal 12 Ocmb0NQDBf|fB*mo2mq`A diff --git a/source/instructions.cpp b/source/instructions.cpp index 8317e26..55bef7e 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -236,7 +236,7 @@ void Instructions::checkEventHandler() } // Bucle para la pantalla de instrucciones -void Instructions::run(mode_e mode) +section_t Instructions::run(mode_e mode) { this->mode = mode; @@ -245,4 +245,6 @@ void Instructions::run(mode_e mode) update(); render(); } + + return section; } diff --git a/source/instructions.h b/source/instructions.h index 0164c7d..b008745 100644 --- a/source/instructions.h +++ b/source/instructions.h @@ -59,7 +59,7 @@ public: ~Instructions(); // Bucle principal - void run(mode_e mode); + section_t run(mode_e mode); }; #endif diff --git a/source/title.cpp b/source/title.cpp index f613dc9..c8ae9cc 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -301,7 +301,10 @@ void Title::update() if (demo) { runDemoGame(); - runInstructions(m_auto); + if (section.name != PROG_SECTION_QUIT) + { + runInstructions(m_auto); + } } else section.name = PROG_SECTION_LOGO; @@ -483,7 +486,10 @@ void Title::update() if (demo) { runDemoGame(); - runInstructions(m_auto); + if (section.name != PROG_SECTION_QUIT) + { + runInstructions(m_auto); + } init(); demo = false; counter = TITLE_COUNTER; @@ -939,19 +945,23 @@ section_t Title::run() } // Ejecuta la parte donde se muestran las instrucciones -void Title::runInstructions(mode_e mode) +section_t Title::runInstructions(mode_e mode) { instructions = new Instructions(renderer, screen, asset, lang); - instructions->run(mode); + section = instructions->run(mode); delete instructions; + + return section; } // Ejecuta el juego en modo demo -void Title::runDemoGame() +section_t Title::runDemoGame() { demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, options); - demoGame->run(); + section = demoGame->run(); delete demoGame; + + return section; } // Modifica las opciones para los controles de los jugadores diff --git a/source/title.h b/source/title.h index 741a2e6..3a50a30 100644 --- a/source/title.h +++ b/source/title.h @@ -117,10 +117,10 @@ private: void applyOptions(); // Ejecuta la parte donde se muestran las instrucciones - void runInstructions(mode_e mode); + section_t runInstructions(mode_e mode); // Ejecuta el juego en modo demo - void runDemoGame(); + section_t runDemoGame(); // Modifica las opciones para los controles de los jugadores bool updatePlayerInputs(int numPlayer);