eliminada la merda de slowmotion i hit
This commit is contained in:
@@ -849,15 +849,11 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &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> &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;
|
||||
|
||||
Reference in New Issue
Block a user