From 3fc15a951203502a5a552ad905ed6025abd4f369 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 17 Aug 2025 19:34:48 +0200 Subject: [PATCH] afegit el fade RANDOM_SQAURE2 canviat els timings del fade a milisegons --- data/config/param_320x240.txt | 13 +- data/config/param_320x256.txt | 13 +- source/defaults.h | 29 ++-- source/director.cpp | 2 +- source/fade.cpp | 244 ++++++++++++++++++++++++++---- source/fade.h | 26 ++-- source/param.cpp | 5 +- source/param.h | 5 +- source/sections/game.cpp | 11 +- source/sections/hiscore_table.cpp | 4 +- source/sections/instructions.cpp | 2 +- source/sections/title.cpp | 4 +- 12 files changed, 274 insertions(+), 84 deletions(-) diff --git a/data/config/param_320x240.txt b/data/config/param_320x240.txt index 01f04d7..2223f71 100644 --- a/data/config/param_320x240.txt +++ b/data/config/param_320x240.txt @@ -16,13 +16,12 @@ game.hit_stop false # Indica si debe haber un paro cuando e game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop # --- FADE --- -fade.color 1F2B30 # Color hexadecimal para el efecto de fundido -fade.num_squares_width 160 # Número de cuadrados en el eje X para el fundido -fade.num_squares_height 120 # Número de cuadrados en el eje Y para el fundido -fade.random_squares_delay 1 # Delay entre aparición de cuadrados aleatorios (frames) -fade.random_squares_mult 500 # Multiplicador para la velocidad de aparición aleatoria -fade.post_duration 80 # Duración tras el fundido (frames) -fade.venetian_size 12 # Tamaño de las bandas para el efecto veneciano (en píxeles) +fade.color 1F2B30 # Color hexadecimal para el efecto de fundido +fade.num_squares_width 64 # Número de cuadrados en el eje X para el fundido +fade.num_squares_height 48 # Número de cuadrados en el eje Y para el fundido +fade.random_squares_duration_ms 1000 # Duración del fade en milisegundos +fade.post_duration_ms 500 # Duración tras el fundido en milisegundos +fade.venetian_size 12 # Tamaño de las bandas para el efecto veneciano (en píxeles) # --- SCOREBOARD --- scoreboard.rect.x 0 # Posición X del marcador diff --git a/data/config/param_320x256.txt b/data/config/param_320x256.txt index f3d48ff..d9029e0 100644 --- a/data/config/param_320x256.txt +++ b/data/config/param_320x256.txt @@ -16,13 +16,12 @@ game.hit_stop false # Indica si debe haber un paro cuando e game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop # --- FADE --- -fade.color 1F2B30 # Color hexadecimal para el efecto de fundido -fade.num_squares_width 160 # Número de cuadrados en el eje X para el fundido -fade.num_squares_height 128 # Número de cuadrados en el eje Y para el fundido -fade.random_squares_delay 1 # Delay entre aparición de cuadrados aleatorios (frames) -fade.random_squares_mult 500 # Multiplicador para la velocidad de aparición aleatoria -fade.post_duration 80 # Duración tras el fundido (frames) -fade.venetian_size 12 # Tamaño de las bandas para el efecto veneciano (en píxeles) +fade.color 1F2B30 # Color hexadecimal para el efecto de fundido +fade.num_squares_width 64 # Número de cuadrados en el eje X para el fundido +fade.num_squares_height 48 # Número de cuadrados en el eje Y para el fundido +fade.random_squares_duration_ms 1000 # Duración del fade en milisegundos +fade.post_duration_ms 500 # Duración tras el fundido en milisegundos +fade.venetian_size 12 # Tamaño de las bandas para el efecto veneciano (en píxeles) # --- SCOREBOARD --- scoreboard.rect.x 0 # Posición X del marcador diff --git a/source/defaults.h b/source/defaults.h index 39f4a39..b2c9407 100644 --- a/source/defaults.h +++ b/source/defaults.h @@ -33,9 +33,8 @@ namespace Fade { constexpr const char* COLOR = "1F2B30"; constexpr float NUM_SQUARES_WIDTH = 160.0F; constexpr float NUM_SQUARES_HEIGHT = 128.0F; -constexpr int RANDOM_SQUARES_DELAY = 1; -constexpr int RANDOM_SQUARES_MULT = 500; -constexpr int POST_DURATION = 80; +constexpr int RANDOM_SQUARES_DURATION_MS = 1; +constexpr int POST_DURATION_MS = 80; constexpr float VENETIAN_SIZE = 12.0F; } // namespace Fade @@ -76,7 +75,8 @@ namespace Balloon { struct BalloonSettings { float vel; float grav; - constexpr BalloonSettings(float v, float g) : vel(v), grav(g) {} + constexpr BalloonSettings(float v, float g) + : vel(v), grav(g) {} }; constexpr std::array SETTINGS = {{ @@ -87,7 +87,10 @@ constexpr std::array SETTINGS = {{ }}; constexpr std::array COLORS = { - "blue", "orange", "red", "green"}; + "blue", + "orange", + "red", + "green"}; constexpr bool BOUNCING_SOUND = false; } // namespace Balloon @@ -154,16 +157,16 @@ constexpr float MAX_SPAWN_TIME = 3.0F; namespace Player { namespace DefaultShirt { // Player 0 (Jugador 1) -constexpr const char* PLAYER0_DARKEST = "028ECFFF"; // 2, 142, 207, 255 -constexpr const char* PLAYER0_DARK = "0297DBFF"; // 2, 151, 219, 255 -constexpr const char* PLAYER0_BASE = "029FE8FF"; // 2, 159, 232, 255 -constexpr const char* PLAYER0_LIGHT = "03A9F4FF"; // 3, 169, 244, 255 +constexpr const char* PLAYER0_DARKEST = "028ECFFF"; // 2, 142, 207, 255 +constexpr const char* PLAYER0_DARK = "0297DBFF"; // 2, 151, 219, 255 +constexpr const char* PLAYER0_BASE = "029FE8FF"; // 2, 159, 232, 255 +constexpr const char* PLAYER0_LIGHT = "03A9F4FF"; // 3, 169, 244, 255 // Player 1 (Jugador 2) -constexpr const char* PLAYER1_DARKEST = "8E8E8EFF"; // 142, 142, 142, 255 -constexpr const char* PLAYER1_DARK = "AEADADFF"; // 174, 173, 173, 255 -constexpr const char* PLAYER1_BASE = "E4E4E4FF"; // 228, 228, 228, 255 -constexpr const char* PLAYER1_LIGHT = "F7F1F1FF"; // 247, 241, 241, 255 +constexpr const char* PLAYER1_DARKEST = "8E8E8EFF"; // 142, 142, 142, 255 +constexpr const char* PLAYER1_DARK = "AEADADFF"; // 174, 173, 173, 255 +constexpr const char* PLAYER1_BASE = "E4E4E4FF"; // 228, 228, 228, 255 +constexpr const char* PLAYER1_LIGHT = "F7F1F1FF"; // 247, 241, 241, 255 } // namespace DefaultShirt namespace OneCoffeeShirt { diff --git a/source/director.cpp b/source/director.cpp index 180287c..3ec6c0c 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -41,7 +41,7 @@ Director::Director(int argc, std::span argv) { Section::name = Section::Name::GAME; Section::options = Section::Options::GAME_PLAY_1P; #elif _DEBUG - Section::name = Section::Name::GAME; + Section::name = Section::Name::TITLE; Section::options = Section::Options::GAME_PLAY_1P; #else // NORMAL GAME Section::name = Section::Name::LOGO; diff --git a/source/fade.cpp b/source/fade.cpp index 0303789..80548d8 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -35,19 +35,22 @@ void Fade::init() { b_ = 0; a_ = 0; post_duration_ = 0; - post_counter_ = 0; + post_start_time_ = 0; pre_duration_ = 0; - pre_counter_ = 0; + pre_start_time_ = 0; num_squares_width_ = param.fade.num_squares_width; num_squares_height_ = param.fade.num_squares_height; - fade_random_squares_delay_ = param.fade.random_squares_delay; - fade_random_squares_mult_ = param.fade.random_squares_mult; + random_squares_duration_ = param.fade.random_squares_duration_ms; // Usar como duración en ms + square_transition_duration_ = random_squares_duration_ / 4; // 25% del tiempo total para la transición individual + random_squares_start_time_ = 0; } // Resetea algunas variables para volver a hacer el fade sin perder ciertos parametros void Fade::reset() { state_ = State::NOT_ENABLED; counter_ = 0; + post_start_time_ = 0; + pre_start_time_ = 0; } // Pinta una transición en pantalla @@ -75,10 +78,11 @@ void Fade::update() { } void Fade::updatePreState() { - if (pre_counter_ == pre_duration_) { + // Sistema basado en tiempo únicamente + Uint32 elapsed_time = SDL_GetTicks() - pre_start_time_; + + if (elapsed_time >= static_cast(pre_duration_)) { state_ = State::FADING; - } else { - pre_counter_++; } } @@ -93,6 +97,9 @@ void Fade::updateFadingState() { case Type::RANDOM_SQUARE: updateRandomSquareFade(); break; + case Type::RANDOM_SQUARE2: + updateRandomSquare2Fade(); + break; case Type::VENETIAN: updateVenetianFade(); break; @@ -102,13 +109,26 @@ void Fade::updateFadingState() { counter_++; } +void Fade::changeToPostState() { + state_ = State::POST; + post_start_time_ = SDL_GetTicks(); +} + void Fade::updatePostState() { - if (post_counter_ == post_duration_) { + // Sistema basado en tiempo únicamente + Uint32 elapsed_time = SDL_GetTicks() - post_start_time_; + + if (elapsed_time >= static_cast(post_duration_)) { state_ = State::FINISHED; - } else { - post_counter_++; } - cleanBackbuffer(r_, g_, b_, a_); + + // Mantener el alpha final correcto para cada tipo de fade + Uint8 post_alpha = a_; + if (type_ == Type::RANDOM_SQUARE2) { + post_alpha = (mode_ == Mode::OUT) ? 255 : 0; + } + + cleanBackbuffer(r_, g_, b_, post_alpha); } void Fade::updateFullscreenFade() { @@ -118,7 +138,7 @@ void Fade::updateFullscreenFade() { // Comprueba si ha terminado if (counter_ >= 255 / 4) { - state_ = State::POST; + changeToPostState(); } } @@ -127,8 +147,8 @@ void Fade::updateCenterFade() { // Comprueba si ha terminado if ((counter_ * 4) > param.game.height) { - state_ = State::POST; a_ = 255; + changeToPostState(); } } @@ -151,20 +171,99 @@ void Fade::drawCenterFadeRectangles() { } void Fade::updateRandomSquareFade() { - if (counter_ % fade_random_squares_delay_ == 0) { - drawRandomSquares(); - } + Uint32 elapsed_time = SDL_GetTicks() - random_squares_start_time_; + float progress = static_cast(elapsed_time) / random_squares_duration_; - value_ = calculateValue(0, (num_squares_width_ * num_squares_height_), (counter_ * fade_random_squares_mult_ / fade_random_squares_delay_)); + // Calcula cuántos cuadrados deberían estar activos + int total_squares = num_squares_width_ * num_squares_height_; + int active_squares = static_cast(progress * total_squares); + active_squares = std::min(active_squares, total_squares); + + // Dibuja los cuadrados activos + drawRandomSquares(active_squares); + + value_ = calculateValue(0, total_squares, active_squares); // Comprueba si ha terminado - if (counter_ * fade_random_squares_mult_ / fade_random_squares_delay_ >= - num_squares_width_ * num_squares_height_) { - state_ = State::POST; + if (elapsed_time >= static_cast(random_squares_duration_)) { + changeToPostState(); } } -void Fade::drawRandomSquares() { +void Fade::updateRandomSquare2Fade() { + Uint32 elapsed_time = SDL_GetTicks() - random_squares_start_time_; + + int total_squares = num_squares_width_ * num_squares_height_; + + // Calcula el tiempo de activación: total - tiempo que necesitan los últimos cuadrados + int activation_time = random_squares_duration_ - square_transition_duration_; + activation_time = std::max(activation_time, square_transition_duration_); // Mínimo igual a la duración de transición + + // Lógica diferente según el modo + int squares_to_activate = 0; + + if (mode_ == Mode::OUT) { + // OUT: Activa cuadrados gradualmente + if (elapsed_time < static_cast(activation_time)) { + float activation_progress = static_cast(elapsed_time) / activation_time; + squares_to_activate = static_cast(activation_progress * total_squares); + } else { + squares_to_activate = total_squares; // Activar todos + } + + // Activa nuevos cuadrados y guarda su tiempo de activación + for (int i = 0; i < squares_to_activate && i < total_squares; ++i) { + if (square_age_[i] == -1) { + square_age_[i] = elapsed_time; // Guarda el tiempo de activación + } + } + } else { + // IN: Todos los cuadrados empiezan activos desde el inicio + squares_to_activate = total_squares; + + // Activa cuadrados gradualmente con tiempo de inicio escalonado + float activation_progress = static_cast(elapsed_time) / activation_time; + int squares_starting_transition = static_cast(activation_progress * total_squares); + + // Asegurar que al menos 1 cuadrado se active desde el primer frame + squares_starting_transition = std::max(squares_starting_transition, 1); + squares_starting_transition = std::min(squares_starting_transition, total_squares); + + for (int i = 0; i < squares_starting_transition; ++i) { + if (square_age_[i] == -1) { + square_age_[i] = elapsed_time; // Empieza la transición a transparente + } + } + } + + drawRandomSquares2(); + + value_ = calculateValue(0, total_squares, squares_to_activate); + + // Comprueba si ha terminado - todos los cuadrados han completado su transición + bool all_completed = (squares_to_activate >= total_squares); + if (all_completed) { + // Verificar que todos han completado su transición individual + for (int i = 0; i < total_squares; ++i) { + if (square_age_[i] >= 0) { // Cuadrado activado + Uint32 square_elapsed = elapsed_time - square_age_[i]; + if (square_elapsed < static_cast(square_transition_duration_)) { + all_completed = false; + break; + } + } + } + + if (all_completed) { + // Pintar textura final: OUT opaca, IN transparente + Uint8 final_alpha = (mode_ == Mode::OUT) ? 255 : 0; + cleanBackbuffer(r_, g_, b_, final_alpha); + changeToPostState(); + } + } +} + +void Fade::drawRandomSquares(int active_count) { auto *temp = SDL_GetRenderTarget(renderer_); SDL_SetRenderTarget(renderer_, backbuffer_); @@ -173,13 +272,56 @@ void Fade::drawRandomSquares() { SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_NONE); SDL_SetRenderDrawColor(renderer_, r_, g_, b_, a_); - const int INDEX = std::min(counter_ / fade_random_squares_delay_, - (num_squares_width_ * num_squares_height_) - 1); + // Dibuja solo los cuadrados activos + for (int i = 0; i < active_count && i < static_cast(square_.size()); ++i) { + SDL_RenderFillRect(renderer_, &square_[i]); + } - for (int i = 0; i < fade_random_squares_mult_; ++i) { - const int INDEX2 = std::min((INDEX * fade_random_squares_mult_) + i, - static_cast(square_.size()) - 1); - SDL_RenderFillRect(renderer_, &square_[INDEX2]); + SDL_SetRenderDrawBlendMode(renderer_, blend_mode); + SDL_SetRenderTarget(renderer_, temp); +} + +void Fade::drawRandomSquares2() { + auto *temp = SDL_GetRenderTarget(renderer_); + SDL_SetRenderTarget(renderer_, backbuffer_); + + // CRÍTICO: Limpiar la textura antes de dibujar + SDL_SetRenderDrawColor(renderer_, 0, 0, 0, 0); + SDL_RenderClear(renderer_); + + SDL_BlendMode blend_mode; + SDL_GetRenderDrawBlendMode(renderer_, &blend_mode); + SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND); // Usar BLEND para alpha + + Uint32 current_time = SDL_GetTicks() - random_squares_start_time_; + + // Lógica unificada: sobre textura transparente, pintar cuadrados según su estado + for (size_t i = 0; i < square_.size(); ++i) { + Uint8 current_alpha = 0; + + if (square_age_[i] == -1) { + // Cuadrado no activado + if (mode_ == Mode::OUT) { + current_alpha = 0; // OUT: transparente si no activado + } else { + current_alpha = a_; // IN: opaco si no activado + } + } else { + // Cuadrado activado - calculamos progreso + Uint32 square_elapsed = current_time - square_age_[i]; + float progress = std::min(static_cast(square_elapsed) / square_transition_duration_, 1.0f); + + if (mode_ == Mode::OUT) { + current_alpha = static_cast(progress * a_); // 0 → 255 + } else { + current_alpha = static_cast((1.0f - progress) * a_); // 255 → 0 + } + } + + if (current_alpha > 0) { + SDL_SetRenderDrawColor(renderer_, r_, g_, b_, current_alpha); + SDL_RenderFillRect(renderer_, &square_[i]); + } } SDL_SetRenderDrawBlendMode(renderer_, blend_mode); @@ -192,7 +334,7 @@ void Fade::updateVenetianFade() { updateVenetianRectangles(); calculateVenetianProgress(); } else { - state_ = State::POST; + changeToPostState(); } } @@ -239,8 +381,7 @@ void Fade::activate() { state_ = State::PRE; counter_ = 0; - post_counter_ = 0; - pre_counter_ = 0; + pre_start_time_ = SDL_GetTicks(); switch (type_) { case Type::FULLSCREEN: { @@ -284,6 +425,49 @@ void Fade::activate() { // Deja el color listo para usar a_ = mode_ == Mode::OUT ? 255 : 0; + // Inicializa el tiempo de inicio + random_squares_start_time_ = SDL_GetTicks(); + + break; + } + + case Type::RANDOM_SQUARE2: { + rect1_ = {.x = 0, .y = 0, .w = static_cast(param.game.width / num_squares_width_), .h = static_cast(param.game.height / num_squares_height_)}; + square_.clear(); + square_age_.clear(); + + // Añade los cuadrados al vector + for (int i = 0; i < num_squares_width_ * num_squares_height_; ++i) { + rect1_.x = (i % num_squares_width_) * rect1_.w; + rect1_.y = (i / num_squares_width_) * rect1_.h; + square_.push_back(rect1_); + square_age_.push_back(-1); // -1 indica cuadrado no activado aún + } + + // Desordena el vector de cuadrados y edades + auto num = num_squares_width_ * num_squares_height_; + while (num > 1) { + auto num_arreu = rand() % num; + SDL_FRect temp_rect = square_[num_arreu]; + int temp_age = square_age_[num_arreu]; + square_[num_arreu] = square_[num - 1]; + square_age_[num_arreu] = square_age_[num - 1]; + square_[num - 1] = temp_rect; + square_age_[num - 1] = temp_age; + num--; + } + + // Textura inicial: OUT transparente, IN opaca + Uint8 initial_alpha = (mode_ == Mode::OUT) ? 0 : 255; + cleanBackbuffer(r_, g_, b_, initial_alpha); + + // Deja el color listo para usar (alpha target para los cuadrados) + a_ = 255; // Siempre usar 255 como alpha target + + // Inicializa el tiempo de inicio y recalcula la duración de transición + random_squares_start_time_ = SDL_GetTicks(); + square_transition_duration_ = std::max(random_squares_duration_ / 4, 100); // Mínimo 100ms + break; } diff --git a/source/fade.h b/source/fade.h index 760f0cc..789e42f 100644 --- a/source/fade.h +++ b/source/fade.h @@ -14,7 +14,8 @@ class Fade { FULLSCREEN = 0, // Fundido de pantalla completa CENTER = 1, // Fundido desde el centro RANDOM_SQUARE = 2, // Fundido con cuadrados aleatorios - VENETIAN = 3, // Fundido tipo persiana veneciana + RANDOM_SQUARE2 = 3, // Fundido con cuadrados aleatorios (variante 2) + VENETIAN = 4, // Fundido tipo persiana veneciana }; enum class Mode : Uint8 { @@ -45,8 +46,8 @@ class Fade { void setColor(Color color); // Establece el color del fade void setType(Type type) { type_ = type; } // Establece el tipo de fade void setMode(Mode mode) { mode_ = mode; } // Establece el modo de fade - void setPostDuration(int value) { post_duration_ = value; } // Duración posterior al fade - void setPreDuration(int value) { pre_duration_ = value; } // Duración previa al fade + void setPostDuration(int value) { post_duration_ = value; } // Duración posterior al fade en milisegundos + void setPreDuration(int value) { pre_duration_ = value; } // Duración previa al fade en milisegundos // --- Getters --- [[nodiscard]] auto getValue() const -> int { return value_; } @@ -60,6 +61,7 @@ class Fade { // --- Variables de estado --- std::vector square_; // Vector de cuadrados + std::vector square_age_; // Edad de cada cuadrado (para RANDOM_SQUARE2) SDL_FRect rect1_, rect2_; // Rectángulos para efectos Type type_; // Tipo de fade Mode mode_; // Modo de fade @@ -68,12 +70,13 @@ class Fade { Uint8 r_, g_, b_, a_; // Color del fade (RGBA) int num_squares_width_; // Cuadrados en horizontal int num_squares_height_; // Cuadrados en vertical - int fade_random_squares_delay_; // Delay entre cuadrados - int fade_random_squares_mult_; // Cuadrados por paso - int post_duration_ = 0; // Duración posterior - int post_counter_ = 0; // Contador posterior - int pre_duration_ = 0; // Duración previa - int pre_counter_ = 0; // Contador previo + Uint32 random_squares_start_time_; // Tiempo de inicio del fade de cuadrados + int random_squares_duration_; // Duración total en milisegundos + int square_transition_duration_; // Duración de transición de cada cuadrado en ms + int post_duration_ = 0; // Duración posterior en milisegundos + Uint32 post_start_time_ = 0; // Tiempo de inicio del estado POST + int pre_duration_ = 0; // Duración previa en milisegundos + Uint32 pre_start_time_ = 0; // Tiempo de inicio del estado PRE int value_ = 0; // Estado del fade (0-100) // --- Inicialización y limpieza --- @@ -87,17 +90,20 @@ class Fade { void updatePreState(); // Actualiza el estado previo al fade void updateFadingState(); // Actualiza el estado durante el fade void updatePostState(); // Actualiza el estado posterior al fade + void changeToPostState(); // Cambia al estado POST e inicializa el tiempo // --- Efectos de fundido (fade) --- void updateFullscreenFade(); // Actualiza el fundido de pantalla completa void updateCenterFade(); // Actualiza el fundido desde el centro void updateRandomSquareFade(); // Actualiza el fundido con cuadrados aleatorios + void updateRandomSquare2Fade(); // Actualiza el fundido con cuadrados aleatorios (variante 2) void updateVenetianFade(); // Actualiza el fundido tipo persiana veneciana void updateVenetianRectangles(); // Actualiza los rectángulos del efecto veneciano void calculateVenetianProgress(); // Calcula el progreso del efecto veneciano // --- Dibujo de efectos visuales --- void drawCenterFadeRectangles(); // Dibuja los rectángulos del fundido central - void drawRandomSquares(); // Dibuja los cuadrados aleatorios del fundido + void drawRandomSquares(int active_count = -1); // Dibuja los cuadrados aleatorios del fundido + void drawRandomSquares2(); // Dibuja los cuadrados con transición de color (RANDOM_SQUARE2) void drawVenetianBlinds(); // Dibuja las persianas venecianas del fundido }; \ No newline at end of file diff --git a/source/param.cpp b/source/param.cpp index f5a0338..b90b94e 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -97,9 +97,8 @@ auto setParams(const std::string& var, const std::string& value) -> bool { {"game.hit_stop_ms", [](const std::string& v) { param.game.hit_stop_ms = std::stoi(v); }}, {"fade.num_squares_width", [](const std::string& v) { param.fade.num_squares_width = std::stoi(v); }}, {"fade.num_squares_height", [](const std::string& v) { param.fade.num_squares_height = std::stoi(v); }}, - {"fade.random_squares_delay", [](const std::string& v) { param.fade.random_squares_delay = std::stoi(v); }}, - {"fade.random_squares_mult", [](const std::string& v) { param.fade.random_squares_mult = std::stoi(v); }}, - {"fade.post_duration", [](const std::string& v) { param.fade.post_duration = std::stoi(v); }}, + {"fade.random_squares_duration_ms", [](const std::string& v) { param.fade.random_squares_duration_ms = std::stoi(v); }}, + {"fade.post_duration_ms", [](const std::string& v) { param.fade.post_duration_ms = std::stoi(v); }}, {"fade.venetian_size", [](const std::string& v) { param.fade.venetian_size = std::stoi(v); }}, {"scoreboard.rect.x", [](const std::string& v) { param.scoreboard.rect.x = std::stoi(v); }}, {"scoreboard.rect.y", [](const std::string& v) { param.scoreboard.rect.y = std::stoi(v); }}, diff --git a/source/param.h b/source/param.h index 7094753..c3a0a86 100644 --- a/source/param.h +++ b/source/param.h @@ -30,9 +30,8 @@ struct ParamFade { Color color = Color::fromHex(GameDefaults::Fade::COLOR); float num_squares_width = GameDefaults::Fade::NUM_SQUARES_WIDTH; float num_squares_height = GameDefaults::Fade::NUM_SQUARES_HEIGHT; - int random_squares_delay = GameDefaults::Fade::RANDOM_SQUARES_DELAY; - int random_squares_mult = GameDefaults::Fade::RANDOM_SQUARES_MULT; - int post_duration = GameDefaults::Fade::POST_DURATION; + int random_squares_duration_ms = GameDefaults::Fade::RANDOM_SQUARES_DURATION_MS; + int post_duration_ms = GameDefaults::Fade::POST_DURATION_MS; float venetian_size = GameDefaults::Fade::VENETIAN_SIZE; }; diff --git a/source/sections/game.cpp b/source/sections/game.cpp index fc13192..5e99827 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -68,14 +68,14 @@ Game::Game(Player::Id player_id, int current_stage, bool demo) scoreboard_ = Scoreboard::get(); fade_in_->setColor(param.fade.color); - fade_in_->setPreDuration(demo_.enabled ? 80 : 0); + fade_in_->setPreDuration(demo_.enabled ? 500 : 0); fade_in_->setPostDuration(0); - fade_in_->setType(Fade::Type::RANDOM_SQUARE); + fade_in_->setType(Fade::Type::RANDOM_SQUARE2); fade_in_->setMode(Fade::Mode::IN); fade_in_->activate(); fade_out_->setColor(param.fade.color); - fade_out_->setPostDuration(param.fade.post_duration); + fade_out_->setPostDuration(param.fade.post_duration_ms); fade_out_->setType(Fade::Type::VENETIAN); background_->setPos(param.game.play_area.rect); @@ -219,7 +219,8 @@ void Game::updatePlayers() { handlePlayerCollision(player, balloon); if (demo_.enabled && allPlayersAreNotPlaying()) { - fade_out_->setType(Fade::Type::RANDOM_SQUARE); + fade_out_->setType(Fade::Type::RANDOM_SQUARE2); + fade_out_->setPostDuration(500); fade_out_->activate(); } } @@ -1651,7 +1652,7 @@ void Game::updateDemo() { // Activa el fundido antes de acabar con los datos de la demo if (demo_.counter == TOTAL_DEMO_DATA - 200) { - fade_out_->setType(Fade::Type::RANDOM_SQUARE); + fade_out_->setType(Fade::Type::RANDOM_SQUARE2); fade_out_->activate(); } diff --git a/source/sections/hiscore_table.cpp b/source/sections/hiscore_table.cpp index b040cb9..04b4628 100644 --- a/source/sections/hiscore_table.cpp +++ b/source/sections/hiscore_table.cpp @@ -264,8 +264,8 @@ void HiScoreTable::updateSprites() { // Inicializa el fade void HiScoreTable::initFade() { fade_->setColor(param.fade.color); - fade_->setType(Fade::Type::RANDOM_SQUARE); - fade_->setPostDuration(param.fade.post_duration); + fade_->setType(Fade::Type::RANDOM_SQUARE2); + fade_->setPostDuration(param.fade.post_duration_ms); fade_->setMode(fade_mode_); fade_->activate(); } diff --git a/source/sections/instructions.cpp b/source/sections/instructions.cpp index bb49ed1..d50ab74 100644 --- a/source/sections/instructions.cpp +++ b/source/sections/instructions.cpp @@ -39,7 +39,7 @@ Instructions::Instructions() tiled_bg_->setColor(param.title.bg_color); fade_->setColor(param.fade.color); fade_->setType(Fade::Type::FULLSCREEN); - fade_->setPostDuration(param.fade.post_duration); + fade_->setPostDuration(param.fade.post_duration_ms); fade_->setMode(Fade::Mode::IN); fade_->activate(); diff --git a/source/sections/title.cpp b/source/sections/title.cpp index e7063e2..0f13386 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -43,8 +43,8 @@ Title::Title() game_logo_->enable(); mini_logo_sprite_->setX(param.game.game_area.center_x - (mini_logo_sprite_->getWidth() / 2)); fade_->setColor(param.fade.color); - fade_->setType(Fade::Type::RANDOM_SQUARE); - fade_->setPostDuration(param.fade.post_duration); + fade_->setType(Fade::Type::RANDOM_SQUARE2); + fade_->setPostDuration(param.fade.post_duration_ms); initPlayers(); // Asigna valores a otras variables