afegit "pulsos" a scoreboard
This commit is contained in:
@@ -287,12 +287,41 @@ void Scoreboard::updateTextSlideAnimation(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las animaciones de pulso de los paneles
|
||||
void Scoreboard::updatePanelPulses(float delta_time) {
|
||||
for (size_t i = 0; i < static_cast<size_t>(Id::SIZE); ++i) {
|
||||
auto& pulse = panel_pulse_.at(i);
|
||||
|
||||
if (!pulse.active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Avanzar el tiempo transcurrido
|
||||
pulse.elapsed_s += delta_time;
|
||||
|
||||
// Desactivar el pulso si ha terminado
|
||||
if (pulse.elapsed_s >= pulse.duration_s) {
|
||||
pulse.active = false;
|
||||
pulse.elapsed_s = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Activa un pulso en el panel especificado
|
||||
void Scoreboard::triggerPanelPulse(Id id, float duration_s) {
|
||||
auto idx = static_cast<size_t>(id);
|
||||
panel_pulse_.at(idx).active = true;
|
||||
panel_pulse_.at(idx).elapsed_s = 0.0f;
|
||||
panel_pulse_.at(idx).duration_s = duration_s;
|
||||
}
|
||||
|
||||
// Actualiza la lógica del marcador
|
||||
void Scoreboard::update(float delta_time) {
|
||||
updateTimeCounter();
|
||||
updateNameColorIndex();
|
||||
updateCarouselAnimation(delta_time);
|
||||
updateTextSlideAnimation(delta_time);
|
||||
updatePanelPulses(delta_time);
|
||||
fillBackgroundTexture(); // Renderizar DESPUÉS de actualizar
|
||||
}
|
||||
|
||||
@@ -334,8 +363,30 @@ void Scoreboard::fillPanelTextures() {
|
||||
// Cambia el destino del renderizador
|
||||
SDL_SetRenderTarget(renderer_, panel_texture_.at(i));
|
||||
|
||||
// Calcula el color de fondo del panel (puede tener pulso activo)
|
||||
Color background_color = Color(0, 0, 0, 0); // Transparente por defecto
|
||||
|
||||
const auto& pulse = panel_pulse_.at(i);
|
||||
if (pulse.active) {
|
||||
// Calcular el progreso del pulso (0.0 a 1.0 y de vuelta a 0.0)
|
||||
float progress = pulse.elapsed_s / pulse.duration_s;
|
||||
|
||||
// Crear curva de ida y vuelta (0 → 1 → 0)
|
||||
float pulse_intensity;
|
||||
if (progress < 0.5F) {
|
||||
pulse_intensity = progress * 2.0F; // 0.0 a 1.0
|
||||
} else {
|
||||
pulse_intensity = (1.0F - progress) * 2.0F; // 1.0 a 0.0
|
||||
}
|
||||
|
||||
// Interpolar entre color base y color aclarado
|
||||
Color target_color = color_.LIGHTEN(PANEL_PULSE_LIGHTEN_AMOUNT);
|
||||
background_color = color_.LERP(target_color, pulse_intensity);
|
||||
background_color.a = 255; // Opaco durante el pulso
|
||||
}
|
||||
|
||||
// Dibuja el fondo de la textura
|
||||
SDL_SetRenderDrawColor(renderer_, 0, 0, 0, 0);
|
||||
SDL_SetRenderDrawColor(renderer_, background_color.r, background_color.g, background_color.b, background_color.a);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
renderPanelContent(i);
|
||||
|
||||
Reference in New Issue
Block a user