From eb713006c6106f1c1233300817e0d6375f471730 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 19 Sep 2023 20:28:48 +0200 Subject: [PATCH] =?UTF-8?q?Corregido=20el=20orden=20de=20ejecuci=C3=B3n=20?= =?UTF-8?q?update-checkEvents-render=20en=20todas=20las=20secciones=20del?= =?UTF-8?q?=20juego=20para=20evitar=20que=20el=20juego=20tarde=20en=20actu?= =?UTF-8?q?alizarse=20cuando=20hay=20muchos=20eventos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/credits.cpp | 6 ++---- source/credits.h | 2 +- source/demo.cpp | 6 ++---- source/demo.h | 2 +- source/ending.cpp | 6 ++---- source/ending.h | 2 +- source/ending2.cpp | 6 ++---- source/ending2.h | 2 +- source/enter_id.cpp | 6 ++---- source/enter_id.h | 2 +- source/game.cpp | 6 ++---- source/game.h | 2 +- source/game_over.cpp | 6 ++---- source/game_over.h | 2 +- source/intro.cpp | 6 ++---- source/intro.h | 2 +- source/logo.cpp | 6 ++---- source/logo.h | 2 +- source/title.cpp | 6 ++---- source/title.h | 2 +- 20 files changed, 30 insertions(+), 50 deletions(-) diff --git a/source/credits.cpp b/source/credits.cpp index 478fa2d0..6da6f87d 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -68,7 +68,7 @@ Credits::~Credits() } // Comprueba el manejador de eventos -void Credits::checkEventHandler() +void Credits::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -290,9 +290,6 @@ void Credits::updateCounter() // Actualiza las variables void Credits::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -350,6 +347,7 @@ void Credits::run() while (section->name == SECTION_PROG_CREDITS) { update(); + checkEvents(); render(); } } diff --git a/source/credits.h b/source/credits.h index 7e8e4c93..3acee3ed 100644 --- a/source/credits.h +++ b/source/credits.h @@ -55,7 +55,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/demo.cpp b/source/demo.cpp index 6986d4cc..e610e101 100644 --- a/source/demo.cpp +++ b/source/demo.cpp @@ -61,7 +61,7 @@ Demo::~Demo() } // Comprueba los eventos de la cola -void Demo::checkEventHandler() +void Demo::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -127,6 +127,7 @@ void Demo::run() while (section->name == SECTION_PROG_DEMO) { update(); + checkEvents(); render(); } } @@ -134,9 +135,6 @@ void Demo::run() // Actualiza el juego, las variables, comprueba la entrada, etc. void Demo::update() { - // Comprueba los eventos de la cola - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { diff --git a/source/demo.h b/source/demo.h index f9d9b21a..b373b176 100644 --- a/source/demo.h +++ b/source/demo.h @@ -55,7 +55,7 @@ private: void render(); // Comprueba los eventos de la cola - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/ending.cpp b/source/ending.cpp index 5ee50edb..2146282f 100644 --- a/source/ending.cpp +++ b/source/ending.cpp @@ -85,9 +85,6 @@ Ending::~Ending() // Actualiza el objeto void Ending::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -147,7 +144,7 @@ void Ending::render() } // Comprueba el manejador de eventos -void Ending::checkEventHandler() +void Ending::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -482,6 +479,7 @@ void Ending::run() while (section->name == SECTION_PROG_ENDING) { update(); + checkEvents(); render(); } diff --git a/source/ending.h b/source/ending.h index 8f95383b..c5149920 100644 --- a/source/ending.h +++ b/source/ending.h @@ -81,7 +81,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/ending2.cpp b/source/ending2.cpp index 95cdb850..ed62cb29 100644 --- a/source/ending2.cpp +++ b/source/ending2.cpp @@ -75,9 +75,6 @@ Ending2::~Ending2() // Actualiza el objeto void Ending2::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -181,7 +178,7 @@ void Ending2::render() } // Comprueba el manejador de eventos -void Ending2::checkEventHandler() +void Ending2::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -239,6 +236,7 @@ void Ending2::run() while (section->name == SECTION_PROG_ENDING2) { update(); + checkEvents(); render(); } diff --git a/source/ending2.h b/source/ending2.h index 21e5262a..bfee7d22 100644 --- a/source/ending2.h +++ b/source/ending2.h @@ -59,7 +59,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/enter_id.cpp b/source/enter_id.cpp index 87f97fc6..4689013c 100644 --- a/source/enter_id.cpp +++ b/source/enter_id.cpp @@ -68,12 +68,13 @@ void EnterID::run() while (section->name == SECTION_PROG_ENTER_ID) { update(); + checkEvents(); render(); } } // Comprueba el manejador de eventos -void EnterID::checkEventHandler() +void EnterID::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -182,9 +183,6 @@ void EnterID::update() // Actualiza el contador de ticks ticks = SDL_GetTicks(); - // Comprueba el manejador de eventos - checkEventHandler(); - // Actualiza el contador counter++; diff --git a/source/enter_id.h b/source/enter_id.h index c60dca9b..1d7ca905 100644 --- a/source/enter_id.h +++ b/source/enter_id.h @@ -49,7 +49,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Inicializa los textos void iniTexts(); diff --git a/source/game.cpp b/source/game.cpp index 517ec775..3f04586e 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -110,7 +110,7 @@ Game::~Game() } // Comprueba los eventos de la cola -void Game::checkEventHandler() +void Game::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -244,6 +244,7 @@ void Game::run() while (section->name == SECTION_PROG_GAME) { update(); + checkEvents(); render(); } @@ -253,9 +254,6 @@ void Game::run() // Actualiza el juego, las variables, comprueba la entrada, etc. void Game::update() { - // Comprueba los eventos de la cola - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { diff --git a/source/game.h b/source/game.h index 5420f81b..30c7be00 100644 --- a/source/game.h +++ b/source/game.h @@ -67,7 +67,7 @@ private: void render(); // Comprueba los eventos de la cola - void checkEventHandler(); + void checkEvents(); #ifdef DEBUG // Pone la información de debug en pantalla diff --git a/source/game_over.cpp b/source/game_over.cpp index 952e5ccb..f88e108e 100644 --- a/source/game_over.cpp +++ b/source/game_over.cpp @@ -57,9 +57,6 @@ GameOver::~GameOver() // Actualiza el objeto void GameOver::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -118,7 +115,7 @@ void GameOver::render() } // Comprueba el manejador de eventos -void GameOver::checkEventHandler() +void GameOver::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -174,6 +171,7 @@ void GameOver::run() while (section->name == SECTION_PROG_GAME_OVER) { update(); + checkEvents(); render(); } } diff --git a/source/game_over.h b/source/game_over.h index 5a864914..a34bc8e4 100644 --- a/source/game_over.h +++ b/source/game_over.h @@ -51,7 +51,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/intro.cpp b/source/intro.cpp index 4ce3ff1f..9fb2f666 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -76,7 +76,7 @@ Intro::~Intro() } // Comprueba el manejador de eventos -void Intro::checkEventHandler() +void Intro::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -199,9 +199,6 @@ void Intro::renderLoad() // Actualiza las variables void Intro::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -250,6 +247,7 @@ void Intro::run() while (section->name == SECTION_PROG_INTRO) { update(); + checkEvents(); render(); } diff --git a/source/intro.h b/source/intro.h index 6ffc86cc..51bf5beb 100644 --- a/source/intro.h +++ b/source/intro.h @@ -54,7 +54,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/logo.cpp b/source/logo.cpp index e9ed8508..dd7eb328 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -70,7 +70,7 @@ Logo::~Logo() } // Comprueba el manejador de eventos -void Logo::checkEventHandler() +void Logo::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -254,9 +254,6 @@ void Logo::update() // Actualiza el contador de ticks ticks = SDL_GetTicks(); - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba las entradas checkInput(); @@ -309,6 +306,7 @@ void Logo::run() while (section->name == SECTION_PROG_LOGO) { update(); + checkEvents(); render(); } } diff --git a/source/logo.h b/source/logo.h index 1c28d178..7b669031 100644 --- a/source/logo.h +++ b/source/logo.h @@ -47,7 +47,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput(); diff --git a/source/title.cpp b/source/title.cpp index 683eb2b1..7a1b5e2b 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -134,7 +134,7 @@ void Title::initMarquee() } // Comprueba el manejador de eventos -void Title::checkEventHandler() +void Title::checkEvents() { // Comprueba los eventos que hay en la cola while (SDL_PollEvent(eventHandler) != 0) @@ -268,9 +268,6 @@ void Title::renderInfo() // Actualiza las variables void Title::update() { - // Comprueba el manejador de eventos - checkEventHandler(); - // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego if (SDL_GetTicks() - ticks > ticksSpeed) { @@ -343,6 +340,7 @@ void Title::run() while (section->name == SECTION_PROG_TITLE) { update(); + checkEvents(); render(); } } diff --git a/source/title.h b/source/title.h index 81677622..f6712e73 100644 --- a/source/title.h +++ b/source/title.h @@ -62,7 +62,7 @@ private: void render(); // Comprueba el manejador de eventos - void checkEventHandler(); + void checkEvents(); // Comprueba las entradas void checkInput();