From dce92136996fbb46692f0f5bbf450f8c3ae81727 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 29 Jul 2025 11:27:25 +0200 Subject: [PATCH] eliminada la merda de slowmotion i hit --- data/config/param_320x240.txt | 22 +++---- data/config/param_320x256.txt | 22 +++---- source/sections/game.cpp | 117 +--------------------------------- source/sections/game.h | 28 -------- 4 files changed, 25 insertions(+), 164 deletions(-) diff --git a/data/config/param_320x240.txt b/data/config/param_320x240.txt index 9da3d8f..82837a5 100644 --- a/data/config/param_320x240.txt +++ b/data/config/param_320x240.txt @@ -1,15 +1,15 @@ ## --- GAME --- -game.item_size 20 # Tamaño de los items del juego (en píxeles) -game.width 320 # Ancho de la resolución nativa del juego (en píxeles) -game.height 240 # Alto de la resolución nativa del juego (en píxeles) -game.play_area.rect.x 0 # Posición X de la zona jugable -game.play_area.rect.y 0 # Posición Y de la zona jugable -game.play_area.rect.w 320 # Ancho de la zona jugable -game.play_area.rect.h 200 # Alto de la zona jugable -game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada -game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida -game.hit_stop true # Indica si debe haber un paro cuando el jugador es golpeado por un globo -game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop +game.item_size 20 # Tamaño de los items del juego (en píxeles) +game.width 320 # Ancho de la resolución nativa del juego (en píxeles) +game.height 240 # Alto de la resolución nativa del juego (en píxeles) +game.play_area.rect.x 0 # Posición X de la zona jugable +game.play_area.rect.y 0 # Posición Y de la zona jugable +game.play_area.rect.w 320 # Ancho de la zona jugable +game.play_area.rect.h 200 # Alto de la zona jugable +game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada +game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida +game.hit_stop false # Indica si debe haber un paro cuando el jugador es golpeado por un globo +game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop ## --- FADE --- fade.color 1F2B30 # Color hexadecimal para el efecto de fundido diff --git a/data/config/param_320x256.txt b/data/config/param_320x256.txt index 4a7185c..e467cd8 100644 --- a/data/config/param_320x256.txt +++ b/data/config/param_320x256.txt @@ -1,15 +1,15 @@ ## --- GAME --- -game.item_size 20 # Tamaño de los items del juego (en píxeles) -game.width 320 # Ancho de la resolución nativa del juego (en píxeles) -game.height 256 # Alto de la resolución nativa del juego (en píxeles) -game.play_area.rect.x 0 # Posición X de la zona jugable -game.play_area.rect.y 0 # Posición Y de la zona jugable -game.play_area.rect.w 320 # Ancho de la zona jugable -game.play_area.rect.h 216 # Alto de la zona jugable -game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada -game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida -game.hit_stop true # Indica si debe haber un paro cuando el jugador es golpeado por un globo -game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop +game.item_size 20 # Tamaño de los items del juego (en píxeles) +game.width 320 # Ancho de la resolución nativa del juego (en píxeles) +game.height 256 # Alto de la resolución nativa del juego (en píxeles) +game.play_area.rect.x 0 # Posición X de la zona jugable +game.play_area.rect.y 0 # Posición Y de la zona jugable +game.play_area.rect.w 320 # Ancho de la zona jugable +game.play_area.rect.h 216 # Alto de la zona jugable +game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada +game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida +game.hit_stop false # Indica si debe haber un paro cuando el jugador es golpeado por un globo +game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop ## --- FADE --- fade.color 1F2B30 # Color hexadecimal para el efecto de fundido diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 16c2a42..2cf0374 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -849,15 +849,11 @@ void Game::handlePlayerCollision(std::shared_ptr &player, std::shared_pt playSound("player_collision.wav"); if (param.game.hit_stop) { pauseMusic(); - auto position = getCollisionPoint(player->getCollider(), balloon->getCollider()); - putHitOnScreen(position); - //SDL_Delay(param.game.hit_stop_ms); - enableSlowMotion(); - //hit_.disable(); - //resumeMusic(); + SDL_Delay(param.game.hit_stop_ms); + resumeMusic(); } screen_->shake(); - //playSound("voice_no.wav"); + playSound("voice_no.wav"); player->setPlayingState(Player::State::ROLLING); sendPlayerToTheBack(player); if (allPlayersAreNotPlaying()) { @@ -888,95 +884,6 @@ void Game::updateTimeStopped() { } } -void Game::updateSlowMotion() { - if (!slow_game_enabled && slow_phase == SlowPhase::NONE) { - return; // No hacer nada si no está activado - } - - Uint32 current_time = SDL_GetTicks(); - - switch (slow_phase) { - case SlowPhase::NONE: - if (slow_game_enabled) { - // Iniciar fase 1: ralentizar - slow_phase = SlowPhase::SLOWING_DOWN; - original_speed = param.game.speed; - maintain_start_time = current_time; // Reutilizar para controlar tiempo de transición - } - break; - - case SlowPhase::SLOWING_DOWN: - { - // Fase 1: Transición suave hacia velocidad lenta basada en TIEMPO - Uint32 transition_duration = slowing_down_duration; - Uint32 elapsed = current_time - maintain_start_time; - - if (elapsed < transition_duration) { - float progress = (float)elapsed / transition_duration; - float smoothed_progress = easeOutCubic(progress); - - param.game.speed = original_speed + - (target_slow_speed - original_speed) * smoothed_progress; - } else { - // Transición completada, pasar a fase 2 - param.game.speed = target_slow_speed; - slow_phase = SlowPhase::MAINTAINING; - maintain_start_time = current_time; // Resetear para fase 2 - } - } - break; - - case SlowPhase::MAINTAINING: - // Fase 2: Comportamiento según la constante CENTRAL_PHASE_BEHAVIOR - if constexpr (CENTRAL_PHASE_BEHAVIOR == CentralPhaseType::SLOW_MOTION) { - // Mantener velocidad lenta durante un tiempo - if (current_time - maintain_start_time >= maintain_duration) { - // Tiempo cumplido, pasar a fase 3 - slow_phase = SlowPhase::SPEEDING_UP; - maintain_start_time = current_time; // Resetear para fase 3 - } - } else if constexpr (CENTRAL_PHASE_BEHAVIOR == CentralPhaseType::FREEZE_TIME) { - // Congelar el tiempo completamente - // No actualizar param.game.speed, mantenerlo "congelado" - // (se podría poner a un valor muy alto para casi pausar) - param.game.speed = 999999; // Prácticamente congela el update del juego - - if (current_time - maintain_start_time >= maintain_duration) { - // Tiempo cumplido, pasar a fase 3 - slow_phase = SlowPhase::SPEEDING_UP; - maintain_start_time = current_time; // Resetear para fase 3 - } - } - break; - - case SlowPhase::SPEEDING_UP: - { - // Fase 3: Transición suave de vuelta a velocidad normal basada en TIEMPO - Uint32 transition_duration = speeding_up_duration; - Uint32 elapsed = current_time - maintain_start_time; - - if (elapsed < transition_duration) { - float progress = (float)elapsed / transition_duration; - float smoothed_progress = easeInCubic(progress); - - param.game.speed = target_slow_speed + - (original_speed - target_slow_speed) * smoothed_progress; - } else { - // Transición completada, finalizar - param.game.speed = original_speed; - slow_phase = SlowPhase::NONE; - slow_game_enabled = false; // Resetear flag - - hit_.disable(); - resumeMusic(); - playSound("voice_no.wav"); - } - } - break; - } -} - -// Actualiza el juego void Game::update() { if (SDL_GetTicks() - ticks_ > param.game.speed) { ticks_ = SDL_GetTicks(); @@ -991,8 +898,6 @@ void Game::update() { fillCanvas(); } - updateSlowMotion(); - static const auto audio = Audio::get(); audio->update(); } @@ -1075,7 +980,6 @@ void Game::fillCanvas() { // Dibuja los objetos background_->render(); renderPlayers(); - renderHit(); renderSmartSprites(); renderItems(); balloon_manager_->render(); @@ -1959,19 +1863,6 @@ void Game::checkServiceMenu() { service_menu_was_active_ = service_menu_is_active; } -// Dibuja el golpe que recibe el jugador al impactarle un globo -void Game::renderHit() { - hit_.render(); -} - -// Coloca el Hit en pantalla obligando a hacer un renderizado -void Game::putHitOnScreen(SDL_FPoint position) { - hit_.create(position); - fillCanvas(); - render(); - hit_.disable(); -} - // Mueve el jugador para pintarlo al fondo de la lista de jugadores void Game::sendPlayerToTheBack(const std::shared_ptr &player) { players_to_put_at_back_.push_back(player); @@ -1990,8 +1881,6 @@ void Game::checkDebugEvents(const SDL_Event &event) { switch (event.key.key) { case SDLK_1: // Crea una powerball { - enableSlowMotion(); - // balloon_manager_->createPowerBall(); //throwCoffee(players_.at(0)->getPosX() + (players_.at(0)->getWidth() / 2), players_.at(0)->getPosY() + (players_.at(0)->getHeight() / 2)); break; diff --git a/source/sections/game.h b/source/sections/game.h index e246f0e..ce53a8c 100644 --- a/source/sections/game.h +++ b/source/sections/game.h @@ -295,37 +295,9 @@ class Game { // --- Utilidades y servicios --- void checkServiceMenu(); // Verifica si el menú de servicio está activo - void renderHit(); // Dibuja el golpe que recibe el jugador al impactarle un globo - void putHitOnScreen(SDL_FPoint position); // Coloca el Hit en pantalla obligando a hacer un renderizado void sendPlayerToTheBack(const std::shared_ptr &player); // Mueve el jugador para pintarlo al fondo de la lista de jugadores void sendPlayerToTheFront(const std::shared_ptr &player); // Mueve el jugador para pintarlo el primero de la lista de jugadores - bool slow_game_enabled = false; - enum class SlowPhase { NONE, - SLOWING_DOWN, - MAINTAINING, - SPEEDING_UP }; - SlowPhase slow_phase = SlowPhase::NONE; - - // Constante para elegir comportamiento de la fase central - enum class CentralPhaseType { - SLOW_MOTION, - FREEZE_TIME - }; - static const CentralPhaseType CENTRAL_PHASE_BEHAVIOR = CentralPhaseType::FREEZE_TIME; - // Cambia a CentralPhaseType::FREEZE_TIME para congelar el tiempo - - float original_speed; - float target_slow_speed = 1000.0f / 15.0f; // Por ejemplo, 30 FPS - - Uint32 maintain_start_time = 0; - Uint32 slowing_down_duration = 0; // 2 segundos manteniendo velocidad lenta - Uint32 maintain_duration = 600; // 2 segundos manteniendo velocidad lenta - Uint32 speeding_up_duration = 2000; // 2 segundos manteniendo velocidad lenta - - void updateSlowMotion(); - void enableSlowMotion() { slow_game_enabled = true; } - // SISTEMA DE GRABACIÓN (CONDICIONAL) #ifdef RECORDING void updateRecording(); // Actualiza variables durante modo de grabación