@@ -1824,8 +1824,8 @@ void Game::setState(State state) {
|
|||||||
playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos
|
playSound("power_ball_explosion.wav"); // Sonido de destruir todos los globos
|
||||||
destroyAllItems(); // Destruye todos los items
|
destroyAllItems(); // Destruye todos los items
|
||||||
background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas
|
background_->setAlpha(0); // Elimina el tono rojo de las últimas pantallas
|
||||||
|
tabe_->disableSpawning(); // Deshabilita la creacion de Tabes
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,4 +210,14 @@ void Tabe::disable() {
|
|||||||
// Detiene/activa el timer
|
// Detiene/activa el timer
|
||||||
void Tabe::pauseTimer(bool value) {
|
void Tabe::pauseTimer(bool value) {
|
||||||
timer_.setPaused(value);
|
timer_.setPaused(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deshabilita el spawning permanentemente
|
||||||
|
void Tabe::disableSpawning() {
|
||||||
|
timer_.setSpawnDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Habilita el spawning nuevamente
|
||||||
|
void Tabe::enableSpawning() {
|
||||||
|
timer_.setSpawnDisabled(false);
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,8 @@ class Tabe {
|
|||||||
void setState(State state); // Establece el estado
|
void setState(State state); // Establece el estado
|
||||||
auto tryToGetBonus() -> bool; // Intenta obtener el bonus
|
auto tryToGetBonus() -> bool; // Intenta obtener el bonus
|
||||||
void pauseTimer(bool value); // Detiene/activa el timer
|
void pauseTimer(bool value); // Detiene/activa el timer
|
||||||
|
void disableSpawning(); // Deshabilita el spawning permanentemente
|
||||||
|
void enableSpawning(); // Habilita el spawning nuevamente
|
||||||
|
|
||||||
// --- Getters ---
|
// --- Getters ---
|
||||||
auto getCollider() -> SDL_FRect& { return sprite_->getRect(); } // Obtiene el área de colisión
|
auto getCollider() -> SDL_FRect& { return sprite_->getRect(); } // Obtiene el área de colisión
|
||||||
@@ -54,7 +56,8 @@ class Tabe {
|
|||||||
Uint32 current_time; // Tiempo actual
|
Uint32 current_time; // Tiempo actual
|
||||||
Uint32 delta_time; // Diferencia de tiempo desde la última actualización
|
Uint32 delta_time; // Diferencia de tiempo desde la última actualización
|
||||||
Uint32 last_time; // Tiempo de la última actualización
|
Uint32 last_time; // Tiempo de la última actualización
|
||||||
bool is_paused{false}; // Indica si el temporizador está pausado
|
bool is_paused{false}; // Indica si el temporizador está pausado (por pausa de juego)
|
||||||
|
bool spawn_disabled{false}; // Indica si el spawning está deshabilitado permanentemente
|
||||||
|
|
||||||
// Constructor - los parámetros min_time y max_time están en mintos
|
// Constructor - los parámetros min_time y max_time están en mintos
|
||||||
Timer(float min_time, float max_time)
|
Timer(float min_time, float max_time)
|
||||||
@@ -75,8 +78,8 @@ class Tabe {
|
|||||||
void update() {
|
void update() {
|
||||||
current_time = SDL_GetTicks();
|
current_time = SDL_GetTicks();
|
||||||
|
|
||||||
// Solo actualizar si no está pausado
|
// Solo actualizar si no está pausado (ni por juego ni por spawn deshabilitado)
|
||||||
if (!is_paused) {
|
if (!is_paused && !spawn_disabled) {
|
||||||
delta_time = current_time - last_time;
|
delta_time = current_time - last_time;
|
||||||
|
|
||||||
if (time_until_next_spawn > delta_time) {
|
if (time_until_next_spawn > delta_time) {
|
||||||
@@ -101,9 +104,20 @@ class Tabe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pausa o reanuda el spawning
|
||||||
|
void setSpawnDisabled(bool disabled) {
|
||||||
|
if (spawn_disabled != disabled) {
|
||||||
|
spawn_disabled = disabled;
|
||||||
|
// Al reactivar, actualizar last_time para evitar saltos
|
||||||
|
if (!disabled) {
|
||||||
|
last_time = SDL_GetTicks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Indica si el temporizador ha finalizado
|
// Indica si el temporizador ha finalizado
|
||||||
[[nodiscard]] auto shouldSpawn() const -> bool {
|
[[nodiscard]] auto shouldSpawn() const -> bool {
|
||||||
return time_until_next_spawn == 0 && !is_paused;
|
return time_until_next_spawn == 0 && !is_paused && !spawn_disabled;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user