Corregido el orden de ejecución update-checkEvents-render en todas las secciones del juego para evitar que el juego tarde en actualizarse cuando hay muchos eventos

This commit is contained in:
2023-09-19 20:28:48 +02:00
parent a07eeff6e4
commit eb713006c6
20 changed files with 30 additions and 50 deletions

View File

@@ -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();
}
}

View File

@@ -55,7 +55,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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)
{

View File

@@ -55,7 +55,7 @@ private:
void render();
// Comprueba los eventos de la cola
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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();
}

View File

@@ -81,7 +81,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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();
}

View File

@@ -59,7 +59,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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++;

View File

@@ -49,7 +49,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Inicializa los textos
void iniTexts();

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -51,7 +51,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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();
}

View File

@@ -54,7 +54,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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();
}
}

View File

@@ -47,7 +47,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();

View File

@@ -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();
}
}

View File

@@ -62,7 +62,7 @@ private:
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
void checkEvents();
// Comprueba las entradas
void checkInput();