From d46e2295fff77e664d20502f1543fd62d1e58bc6 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 1 Nov 2025 22:52:56 +0100 Subject: [PATCH] style: en els update() de game/scenes --- source/game/scenes/credits.cpp | 1 - source/game/scenes/ending.cpp | 1 - source/game/scenes/ending2.cpp | 1 - source/game/scenes/game.cpp | 28 +++++++++++++++------------ source/game/scenes/game_over.cpp | 1 - source/game/scenes/loading_screen.cpp | 2 -- source/game/scenes/logo.cpp | 1 - source/game/scenes/title.cpp | 1 - 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/source/game/scenes/credits.cpp b/source/game/scenes/credits.cpp index bb9caa5..bf21550 100644 --- a/source/game/scenes/credits.cpp +++ b/source/game/scenes/credits.cpp @@ -155,7 +155,6 @@ void Credits::fillTexture() { // Actualiza las variables void Credits::update() { - // Obtiene el delta time const float DELTA_TIME = delta_timer_->tick(); total_time_ += DELTA_TIME; // Actualiza el tiempo total diff --git a/source/game/scenes/ending.cpp b/source/game/scenes/ending.cpp index ffb087e..96edd5f 100644 --- a/source/game/scenes/ending.cpp +++ b/source/game/scenes/ending.cpp @@ -46,7 +46,6 @@ Ending::Ending() // Actualiza el objeto void Ending::update() { - // Obtiene el delta time const float DELTA_TIME = delta_timer_->tick(); total_time_ += DELTA_TIME; // Actualiza el tiempo total diff --git a/source/game/scenes/ending2.cpp b/source/game/scenes/ending2.cpp index 7f48b0c..f961cf9 100644 --- a/source/game/scenes/ending2.cpp +++ b/source/game/scenes/ending2.cpp @@ -54,7 +54,6 @@ Ending2::Ending2() // Actualiza el objeto void Ending2::update() { - // Obtiene el delta time const float DELTA_TIME = delta_timer_->tick(); handleEvents(); // Comprueba los eventos diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 9d6e421..6c3fdd9 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -116,7 +116,6 @@ void Game::run() { // Actualiza el juego, las variables, comprueba la entrada, etc. void Game::update() { - // Calcula el delta time const float DELTA_TIME = delta_timer_.tick(); handleEvents(); // Comprueba los eventos @@ -128,18 +127,23 @@ void Game::update() { // Actualiza los objetos room_->update(DELTA_TIME); - if (mode_ == Mode::GAME) { - player_->update(DELTA_TIME); - checkPlayerIsOnBorder(); - checkPlayerAndItems(); - checkPlayerAndEnemies(); - checkIfPlayerIsAlive(); - checkGameOver(); - checkEndGame(); - checkRestoringJail(DELTA_TIME); - checkSomeCheevos(); + switch (mode_) { + case Mode::GAME: + player_->update(DELTA_TIME); + checkPlayerIsOnBorder(); + checkPlayerAndItems(); + checkPlayerAndEnemies(); + checkIfPlayerIsAlive(); + checkGameOver(); + checkEndGame(); + checkRestoringJail(DELTA_TIME); + checkSomeCheevos(); + break; + + case Mode::DEMO: + demoCheckRoomChange(DELTA_TIME); + break; } - demoCheckRoomChange(DELTA_TIME); scoreboard_->update(DELTA_TIME); keepMusicPlaying(); updateBlackScreen(DELTA_TIME); diff --git a/source/game/scenes/game_over.cpp b/source/game/scenes/game_over.cpp index c05c69f..3333907 100644 --- a/source/game/scenes/game_over.cpp +++ b/source/game/scenes/game_over.cpp @@ -45,7 +45,6 @@ GameOver::GameOver() // Actualiza el objeto void GameOver::update() { - // Obtiene el delta time desde el último frame const float DELTA_TIME = delta_timer_->tick(); elapsed_time_ += DELTA_TIME; diff --git a/source/game/scenes/loading_screen.cpp b/source/game/scenes/loading_screen.cpp index 6f2823a..174d70d 100644 --- a/source/game/scenes/loading_screen.cpp +++ b/source/game/scenes/loading_screen.cpp @@ -322,7 +322,6 @@ void LoadingScreen::renderWhiteBorder() { // Actualiza las variables void LoadingScreen::update() { - // Obtener delta time desde el último frame const float DELTA_TIME = delta_timer_->tick(); handleEvents(); // Comprueba los eventos @@ -355,7 +354,6 @@ void LoadingScreen::update() { break; } - // Singletones Audio::update(); // Actualiza el objeto Audio Screen::get()->update(DELTA_TIME); // Actualiza el objeto Screen } diff --git a/source/game/scenes/logo.cpp b/source/game/scenes/logo.cpp index 00dbffa..63d9b2f 100644 --- a/source/game/scenes/logo.cpp +++ b/source/game/scenes/logo.cpp @@ -180,7 +180,6 @@ void Logo::updateState(float delta_time) { // Actualiza las variables void Logo::update() { - // Obtener delta time desde el último frame const float DELTA_TIME = delta_timer_->tick(); handleEvents(); // Comprueba los eventos diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 3203967..691b431 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -170,7 +170,6 @@ void Title::renderMarquee() { // Actualiza las variables void Title::update() { - // Obtener delta time const float DELTA_TIME = delta_timer_->tick(); handleEvents(); // Comprueba los eventos