delay en naus en titol
This commit is contained in:
@@ -479,6 +479,9 @@ constexpr float FLOAT_PHASE_OFFSET = 1.57f; // π/2 (90°)
|
|||||||
constexpr float P1_ENTRY_DELAY = 0.0f; // P1 entra immediatament
|
constexpr float P1_ENTRY_DELAY = 0.0f; // P1 entra immediatament
|
||||||
constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
|
constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
|
||||||
|
|
||||||
|
// Delay global abans d'iniciar l'animació d'entrada al estat MAIN
|
||||||
|
constexpr float ENTRANCE_DELAY = 5.0f; // Temps d'espera abans que les naus entrin
|
||||||
|
|
||||||
// Multiplicadors de freqüència per a cada nau (variació sutil ±12%)
|
// Multiplicadors de freqüència per a cada nau (variació sutil ±12%)
|
||||||
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88f; // 12% més lenta
|
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88f; // 12% més lenta
|
||||||
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12f; // 12% més ràpida
|
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12f; // 12% més ràpida
|
||||||
|
|||||||
@@ -362,15 +362,21 @@ void EscenaTitol::actualitzar(float delta_time) {
|
|||||||
animacio_activa_ = false; // Comença estàtic
|
animacio_activa_ = false; // Comença estàtic
|
||||||
factor_lerp_ = 0.0f; // Sense animació encara
|
factor_lerp_ = 0.0f; // Sense animació encara
|
||||||
|
|
||||||
// Iniciar animació d'entrada de naus
|
// Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí)
|
||||||
ship_animator_->set_visible(true);
|
|
||||||
ship_animator_->start_entry_animation();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EstatTitol::MAIN: {
|
case EstatTitol::MAIN: {
|
||||||
temps_estat_main_ += delta_time;
|
temps_estat_main_ += delta_time;
|
||||||
|
|
||||||
|
// Iniciar animació d'entrada de naus després del delay
|
||||||
|
if (temps_estat_main_ >= Defaults::Title::Ships::ENTRANCE_DELAY) {
|
||||||
|
if (ship_animator_ && !ship_animator_->is_visible()) {
|
||||||
|
ship_animator_->set_visible(true);
|
||||||
|
ship_animator_->start_entry_animation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fase 1: Estàtic (0-10s)
|
// Fase 1: Estàtic (0-10s)
|
||||||
if (temps_estat_main_ < DELAY_INICI_ANIMACIO) {
|
if (temps_estat_main_ < DELAY_INICI_ANIMACIO) {
|
||||||
factor_lerp_ = 0.0f;
|
factor_lerp_ = 0.0f;
|
||||||
@@ -458,9 +464,7 @@ void EscenaTitol::actualitzar(float delta_time) {
|
|||||||
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
|
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
|
||||||
temps_estat_main_ = 0.0f;
|
temps_estat_main_ = 0.0f;
|
||||||
|
|
||||||
// Iniciar animació d'entrada de naus
|
// Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí)
|
||||||
ship_animator_->set_visible(true);
|
|
||||||
ship_animator_->start_entry_animation();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +475,12 @@ void EscenaTitol::actualitzar(float delta_time) {
|
|||||||
bool p2_actiu_abans = config_partida_.jugador2_actiu;
|
bool p2_actiu_abans = config_partida_.jugador2_actiu;
|
||||||
|
|
||||||
if (checkStartGameButtonPressed()) {
|
if (checkStartGameButtonPressed()) {
|
||||||
|
// Si START es prem durant el delay (naus encara invisibles), saltar-les a FLOATING
|
||||||
|
if (ship_animator_ && !ship_animator_->is_visible()) {
|
||||||
|
ship_animator_->set_visible(true);
|
||||||
|
ship_animator_->skip_to_floating_state();
|
||||||
|
}
|
||||||
|
|
||||||
// Configurar partida abans de canviar d'escena
|
// Configurar partida abans de canviar d'escena
|
||||||
context_.set_config_partida(config_partida_);
|
context_.set_config_partida(config_partida_);
|
||||||
std::cout << "[EscenaTitol] Configuració de partida - P1: "
|
std::cout << "[EscenaTitol] Configuració de partida - P1: "
|
||||||
|
|||||||
@@ -101,6 +101,32 @@ void ShipAnimator::trigger_exit_animation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShipAnimator::skip_to_floating_state() {
|
||||||
|
// Posar ambdues naus directament en estat FLOATING
|
||||||
|
for (auto& nau : naus_) {
|
||||||
|
nau.estat = EstatNau::FLOATING;
|
||||||
|
nau.temps_estat = 0.0f;
|
||||||
|
nau.fase_oscilacio = 0.0f;
|
||||||
|
|
||||||
|
// Posar en posició objectiu (sense animació)
|
||||||
|
nau.posicio_actual = nau.posicio_objectiu;
|
||||||
|
nau.escala_actual = nau.escala_objectiu;
|
||||||
|
|
||||||
|
// NO establir visibilitat aquí - ja ho fa el caller
|
||||||
|
// (evita fer visibles ambdues naus quan només una ha premut START)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShipAnimator::is_visible() const {
|
||||||
|
// Retorna true si almenys una nau és visible
|
||||||
|
for (const auto& nau : naus_) {
|
||||||
|
if (nau.visible) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ShipAnimator::trigger_exit_animation_for_player(int jugador_id) {
|
void ShipAnimator::trigger_exit_animation_for_player(int jugador_id) {
|
||||||
// Trobar la nau del jugador especificat
|
// Trobar la nau del jugador especificat
|
||||||
for (auto& nau : naus_) {
|
for (auto& nau : naus_) {
|
||||||
|
|||||||
@@ -73,10 +73,12 @@ class ShipAnimator {
|
|||||||
void start_entry_animation();
|
void start_entry_animation();
|
||||||
void trigger_exit_animation(); // Anima totes les naus
|
void trigger_exit_animation(); // Anima totes les naus
|
||||||
void trigger_exit_animation_for_player(int jugador_id); // Anima només una nau (P1=1, P2=2)
|
void trigger_exit_animation_for_player(int jugador_id); // Anima només una nau (P1=1, P2=2)
|
||||||
|
void skip_to_floating_state(); // Salta directament a FLOATING sense animació
|
||||||
|
|
||||||
// Control de visibilitat
|
// Control de visibilitat
|
||||||
void set_visible(bool visible);
|
void set_visible(bool visible);
|
||||||
bool is_animation_complete() const;
|
bool is_animation_complete() const;
|
||||||
|
bool is_visible() const; // Comprova si alguna nau és visible
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Renderer* renderer_;
|
SDL_Renderer* renderer_;
|
||||||
|
|||||||
Reference in New Issue
Block a user