magic numbers: game.cpp

This commit is contained in:
2025-09-19 07:33:27 +02:00
parent 5c82916650
commit af7cb01ead
2 changed files with 7 additions and 6 deletions

View File

@@ -328,16 +328,17 @@ void Game::updateGameStateGameOver(float deltaTime) {
checkBulletCollision();
cleanVectors();
if (game_over_counter_ > 0) {
if (game_over_counter_ >= GAME_OVER_DURATION_MS) {
if (game_over_timer_ > 0) {
if (game_over_timer_ >= GAME_OVER_DURATION_MS) {
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
Audio::get()->fadeOutMusic(1000);
balloon_manager_->setBouncingSounds(true);
}
game_over_counter_--;
game_over_timer_ -= deltaTime; // Decremento time-based
if (game_over_counter_ == 150) {
constexpr float FADE_TRIGGER_MS = 150.0f * (1000.0f / 60.0f); // 150 frames = 2500ms
if (game_over_timer_ <= FADE_TRIGGER_MS && !fade_out_->isEnabled()) {
fade_out_->activate();
}
}
@@ -2043,7 +2044,7 @@ void Game::handleGameCompletedEvents() {
// Maneja eventos de game over usando flag para trigger único
void Game::handleGameOverEvents() {
static bool game_over_triggered = false;
if (!game_over_triggered && game_over_counter_ >= GAME_OVER_DURATION_MS) {
if (!game_over_triggered && game_over_timer_ >= GAME_OVER_DURATION_MS) {
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
Audio::get()->fadeOutMusic(1000);
balloon_manager_->setBouncingSounds(true);

View File

@@ -156,7 +156,7 @@ class Game {
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
float counter_ = 0; // Contador para el juego
float game_completed_counter_ = 0; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más globos
float game_over_counter_ = GAME_OVER_DURATION_MS; // Contador para el estado de fin de partida
float game_over_timer_ = GAME_OVER_DURATION_MS; // Timer para el estado de fin de partida (milisegundos)
float time_stopped_counter_ = 0; // Temporizador para llevar la cuenta del tiempo detenido
int menace_ = 0; // Nivel de amenaza actual
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos