From faba87c06dc0d9585dfa47eb623e5fbf2c22b6ac Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 27 Nov 2024 18:39:23 +0100 Subject: [PATCH] =?UTF-8?q?FIX:=20Si=20saltes=20el=20logo=20talla=20el=20s?= =?UTF-8?q?o=20a=20meitat=20sonar=20FIX:=20Corregida=20la=20l=C3=B2gica=20?= =?UTF-8?q?del=20efecte=20de=20flash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/credits.cpp | 2 +- source/director.cpp | 4 ++-- source/game.cpp | 4 ++-- source/logo.cpp | 1 + source/screen.cpp | 18 ++++++++++++------ source/screen.h | 9 ++++++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/source/credits.cpp b/source/credits.cpp index d495ee4..35cecc3 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -172,7 +172,7 @@ void Credits::checkInput() { // Si todavía estan los creditos en marcha, se pasan solos a toda pastilla want_to_pass_ = true; - ticks_speed_ = 3; + ticks_speed_ = 1; } } diff --git a/source/director.cpp b/source/director.cpp index bd55889..c120432 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -53,7 +53,7 @@ Director::Director(int argc, const char *argv[]) section::name = section::Name::GAME; section::options = section::Options::GAME_PLAY_1P; #elif DEBUG - section::name = section::Name::CREDITS; + section::name = section::Name::LOGO; #else // NORMAL GAME section::name = section::Name::LOGO; section::attract_mode = section::AttractMode::TITLE_TO_DEMO; @@ -105,7 +105,7 @@ void Director::init() Resource::init(); Input::init(Asset::get()->get("gamecontrollerdb.txt")); bindInputs(); - Notifier::init(std::string(), Resource::get()->getText("8bithud"), Asset::get()->get("notify.wav")); + Notifier::init(std::string(), Resource::get()->getText("8bithud")); OnScreenHelp::init(); globalInputs::init(); } diff --git a/source/game.cpp b/source/game.cpp index d0aec86..88d3dc1 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -253,7 +253,7 @@ void Game::updateStage() ++Stage::number; JA_PlaySound(Resource::get()->getSound("stage_change.wav")); balloon_manager_->resetBalloonSpeed(); - screen_->flash(flash_color, 100); + screen_->flash(flash_color, 3); screen_->shake(); // Escribe el texto por pantalla @@ -1169,7 +1169,7 @@ void Game::checkEvents() } case SDLK_7: // Flash { - screen_->flash(flash_color, 100); + screen_->flash(flash_color, 3); break; } case SDLK_8: diff --git a/source/logo.cpp b/source/logo.cpp index ab9b062..9d12b48 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -59,6 +59,7 @@ Logo::~Logo() { jail_texture_->setColor(255, 255, 255); since_texture_->setColor(255, 255, 255); + JA_PauseChannel(-1); } // Recarga todas las texturas diff --git a/source/screen.cpp b/source/screen.cpp index 28f8573..8c57454 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -88,10 +88,10 @@ void Screen::blit() fps_counter_++; // Actualiza y dibuja el efecto de flash en la pantalla - doFlash(); + renderFlash(); // Atenua la pantalla - doAttenuate(); + renderAttenuate(); // Muestra la ayuda por pantalla OnScreenHelp::get()->render(); @@ -254,6 +254,7 @@ void Screen::setBlendMode(SDL_BlendMode blendMode) void Screen::update() { updateShakeEffect(); + updateFlash(); Notifier::get()->update(); updateFPS(); OnScreenHelp::get()->update(); @@ -312,21 +313,26 @@ void Screen::flash(Color color, int lenght) } // Actualiza y dibuja el efecto de flash en la pantalla -void Screen::doFlash() +void Screen::renderFlash() { if (flash_effect_.enabled) { - // Dibuja el color del flash en la textura SDL_SetRenderDrawColor(renderer_, flash_effect_.color.r, flash_effect_.color.g, flash_effect_.color.b, 0xFF); SDL_RenderClear(renderer_); + } +} - // Actualiza la lógica del efecto +// Actualiza el efecto de flash +void Screen::updateFlash() +{ + if (flash_effect_.enabled) + { flash_effect_.counter > 0 ? flash_effect_.counter-- : flash_effect_.enabled = false; } } // Atenua la pantalla -void Screen::doAttenuate() +void Screen::renderAttenuate() { if (attenuate_effect_) { diff --git a/source/screen.h b/source/screen.h index 2778d9c..fba9dcb 100644 --- a/source/screen.h +++ b/source/screen.h @@ -82,11 +82,14 @@ private: // Actualiza la logica para agitar la pantalla void updateShakeEffect(); - // Actualiza y dibuja el efecto de flash en la pantalla - void doFlash(); + // Dibuja el efecto de flash en la pantalla + void renderFlash(); + + // Actualiza el efecto de flash + void updateFlash(); // Atenua la pantalla - void doAttenuate(); + void renderAttenuate(); // Calcula los frames por segundo void updateFPS();