Files
orni-attack/source/game/effects/firework.hpp

47 lines
1.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// firework.hpp - Partícula d'efecte starburst (una línia per partícula)
// © 2026 JailDesigner
#pragma once
#include <SDL3/SDL.h>
#include "core/types.hpp"
namespace Effects {
// Una partícula de firework: una línia que neix d'un punt origen, viatja
// radialment cap a fora i s'encongeix conforme perd velocitat.
//
// Geometria (es deriva al draw):
// head: extrem davanter (es mou amb velocity).
// tail = head velocity_normalitzada × current_length.
//
// Cicle de vida:
// Fase 1 (elapsed_time < grow_duration): current_length creix linealment
// de 0 a max_length. Brillor al màxim.
// Fase 2: current_length = max_length × (speed/initial_speed) i brillor
// amb la mateixa proporció. Mor quan length o brightness cauen sota
// llindar.
struct Firework {
Vec2 head; // Punta davantera (posició actual)
Vec2 velocity; // Velocidad en px/s
float acceleration; // Fricció lineal (px/s², negativa)
float current_length; // Longitud actual del segment (px)
float max_length; // Longitud màxima (final de la fase de creixement)
float grow_duration; // Temps de creixement de 0 a max_length (s)
float elapsed_time; // Acumulador (s)
float initial_speed; // Speed inicial per a la proporció de fase 2
float brightness; // 0..1
SDL_Color color{}; // alpha==0 → oscilador global
// Halo neon (off per defecte). Si glow_color.a > 0, el halo usa
// glow_color (línia blanca + halo daurat, p.ex.); si alpha==0, el
// halo agafa el color de la línia.
bool glow{false};
SDL_Color glow_color{};
bool active;
};
} // namespace Effects