eliminada la merda de slowmotion i hit
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
## --- GAME ---
|
## --- GAME ---
|
||||||
game.item_size 20 # Tamaño de los items del juego (en píxeles)
|
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.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.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.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.y 0 # Posición Y de la zona jugable
|
||||||
game.play_area.rect.w 320 # Ancho 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.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_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.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 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
|
game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop
|
||||||
|
|
||||||
## --- FADE ---
|
## --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
## --- GAME ---
|
## --- GAME ---
|
||||||
game.item_size 20 # Tamaño de los items del juego (en píxeles)
|
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.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.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.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.y 0 # Posición Y de la zona jugable
|
||||||
game.play_area.rect.w 320 # Ancho 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.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_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.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 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
|
game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop
|
||||||
|
|
||||||
## --- FADE ---
|
## --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
|
|||||||
@@ -849,15 +849,11 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_pt
|
|||||||
playSound("player_collision.wav");
|
playSound("player_collision.wav");
|
||||||
if (param.game.hit_stop) {
|
if (param.game.hit_stop) {
|
||||||
pauseMusic();
|
pauseMusic();
|
||||||
auto position = getCollisionPoint(player->getCollider(), balloon->getCollider());
|
SDL_Delay(param.game.hit_stop_ms);
|
||||||
putHitOnScreen(position);
|
resumeMusic();
|
||||||
//SDL_Delay(param.game.hit_stop_ms);
|
|
||||||
enableSlowMotion();
|
|
||||||
//hit_.disable();
|
|
||||||
//resumeMusic();
|
|
||||||
}
|
}
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
//playSound("voice_no.wav");
|
playSound("voice_no.wav");
|
||||||
player->setPlayingState(Player::State::ROLLING);
|
player->setPlayingState(Player::State::ROLLING);
|
||||||
sendPlayerToTheBack(player);
|
sendPlayerToTheBack(player);
|
||||||
if (allPlayersAreNotPlaying()) {
|
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() {
|
void Game::update() {
|
||||||
if (SDL_GetTicks() - ticks_ > param.game.speed) {
|
if (SDL_GetTicks() - ticks_ > param.game.speed) {
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
@@ -991,8 +898,6 @@ void Game::update() {
|
|||||||
fillCanvas();
|
fillCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSlowMotion();
|
|
||||||
|
|
||||||
static const auto audio = Audio::get();
|
static const auto audio = Audio::get();
|
||||||
audio->update();
|
audio->update();
|
||||||
}
|
}
|
||||||
@@ -1075,7 +980,6 @@ void Game::fillCanvas() {
|
|||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
background_->render();
|
background_->render();
|
||||||
renderPlayers();
|
renderPlayers();
|
||||||
renderHit();
|
|
||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
renderItems();
|
renderItems();
|
||||||
balloon_manager_->render();
|
balloon_manager_->render();
|
||||||
@@ -1959,19 +1863,6 @@ void Game::checkServiceMenu() {
|
|||||||
service_menu_was_active_ = service_menu_is_active;
|
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
|
// Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
||||||
void Game::sendPlayerToTheBack(const std::shared_ptr<Player> &player) {
|
void Game::sendPlayerToTheBack(const std::shared_ptr<Player> &player) {
|
||||||
players_to_put_at_back_.push_back(player);
|
players_to_put_at_back_.push_back(player);
|
||||||
@@ -1990,8 +1881,6 @@ void Game::checkDebugEvents(const SDL_Event &event) {
|
|||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
case SDLK_1: // Crea una powerball
|
case SDLK_1: // Crea una powerball
|
||||||
{
|
{
|
||||||
enableSlowMotion();
|
|
||||||
|
|
||||||
// balloon_manager_->createPowerBall();
|
// balloon_manager_->createPowerBall();
|
||||||
//throwCoffee(players_.at(0)->getPosX() + (players_.at(0)->getWidth() / 2), players_.at(0)->getPosY() + (players_.at(0)->getHeight() / 2));
|
//throwCoffee(players_.at(0)->getPosX() + (players_.at(0)->getWidth() / 2), players_.at(0)->getPosY() + (players_.at(0)->getHeight() / 2));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -295,37 +295,9 @@ class Game {
|
|||||||
// --- Utilidades y servicios ---
|
// --- Utilidades y servicios ---
|
||||||
void checkServiceMenu(); // Verifica si el menú de servicio está activo
|
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> &player); // Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
void sendPlayerToTheBack(const std::shared_ptr<Player> &player); // Mueve el jugador para pintarlo al fondo de la lista de jugadores
|
||||||
void sendPlayerToTheFront(const std::shared_ptr<Player> &player); // Mueve el jugador para pintarlo el primero de la lista de jugadores
|
void sendPlayerToTheFront(const std::shared_ptr<Player> &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)
|
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
void updateRecording(); // Actualiza variables durante modo de grabación
|
void updateRecording(); // Actualiza variables durante modo de grabación
|
||||||
|
|||||||
Reference in New Issue
Block a user