From c2c55707c3f7b8f2fb172ba34d0b447022e741f4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 15 Mar 2025 19:53:57 +0100 Subject: [PATCH] al acabar la partida i vore els records, torna al titol --- source/fade.cpp | 7 +++---- source/game.cpp | 1 + source/hiscore_table.cpp | 5 ++++- source/section.h | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/fade.cpp b/source/fade.cpp index cb0b20c..753e1c7 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -22,7 +22,6 @@ Fade::Fade() Fade::~Fade() { SDL_DestroyTexture(backbuffer_); - backbuffer_ = nullptr; } // Inicializa las variables @@ -141,11 +140,11 @@ void Fade::update() SDL_SetRenderDrawColor(renderer_, r_, g_, b_, a_); // Dibuja el cuadrado correspondiente - const int index = std::min(counter_ / fade_random_squares_delay_, (num_squares_width_ * num_squares_height_) - 1); + const int INDEX = std::min(counter_ / fade_random_squares_delay_, (num_squares_width_ * num_squares_height_) - 1); for (int i = 0; i < fade_random_squares_mult_; ++i) { - const int index2 = std::min(index * fade_random_squares_mult_ + i, (int)square_.size() - 1); - SDL_RenderFillRect(renderer_, &square_[index2]); + const int INDEX2 = std::min(INDEX * fade_random_squares_mult_ + i, (int)square_.size() - 1); + SDL_RenderFillRect(renderer_, &square_[INDEX2]); } // Deja el renderizador como estaba diff --git a/source/game.cpp b/source/game.cpp index afedf2d..bac582b 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -346,6 +346,7 @@ void Game::updateGameStateGameOver() { // La partida ha terminado con la derrota de los jugadores section::name = section::Name::HI_SCORE_TABLE; + section::options = section::Options::HI_SCORE_AFTER_GAME_OVER; } if (options.audio.enabled) { diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 6c7d4ef..b3f3763 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -176,7 +176,10 @@ void HiScoreTable::updateFade() if (fade_->hasEnded() && fade_mode_ == FadeMode::OUT) { - section::name = section::Name::INSTRUCTIONS; + section::name = (section::options == section::Options::HI_SCORE_AFTER_GAME_OVER) + ? section::Name::TITLE + : section::Name::INSTRUCTIONS; + section::options = section::Options::NONE; } } diff --git a/source/section.h b/source/section.h index 732fc67..0b07c38 100644 --- a/source/section.h +++ b/source/section.h @@ -29,6 +29,7 @@ namespace section QUIT_WITH_CONTROLLER, QUIT_FROM_EVENT, RELOAD, + HI_SCORE_AFTER_GAME_OVER, NONE, };