7ee359b910
Sweep final del naming a CamelCase/camelBack/lower_case:
Fitxers renombrats:
- effects/gestor_puntuacio_flotant.{hpp,cpp} -> floating_score_manager.{hpp,cpp}
- effects/puntuacio_flotant.hpp -> floating_score.hpp
Tipus (CamelCase):
- GestorPuntuacioFlotant -> FloatingScoreManager
- PuntuacioFlotant -> FloatingScore
- ConfigStage -> StageConfig
- ConfigSistemaStages -> StageSystemConfig
- NauTitol -> TitleShip
- EstatNau -> ShipState
Metodes publics (camelBack):
- obte_renderer -> getRenderer
- get_num_actius -> getActiveCount
- calcular_direccio_explosio -> computeExplosionDirection
- trobar_slot_lliure -> findFreeSlot
- explotar -> explode
- reiniciar -> reset
- es_valida -> isValid
- parsejar_fitxer -> parseFile
- carregar -> load
- crear_explosio -> createExplosion
- registrar_puntuacio -> registerScore
- construir_marcador -> buildScoreboard
- render_centered -> renderCentered
Camps struct publics (snake_case):
- actiu/actius -> active
- rotacio -> rotation, rotacio_visual -> visual_rotation
- acceleracio -> acceleration
- velocitat -> velocity
- escala/escala_inicial/objectiu/actual -> scale/initial_scale/...
- posicio/posicio_inicial/objectiu/actual -> position/initial_position/...
- fase_oscilacio -> oscillation_phase
- temps_estat -> state_time
- jugador_id -> player_id
- estat -> state
- brillantor -> brightness
- tipus -> type
Camps privats (sufix _):
- naus_ -> ships_, orni_ -> enemies_, bales_ -> bullets_
- gestor_puntuacio_ -> floating_score_manager_
- punt_mort_ -> death_position_, punt_spawn_ -> spawn_position_
- itocado_per_jugador_ -> hit_timer_per_player_
- vides_per_jugador_ -> lives_per_player_
- puntuacio_per_jugador_ -> score_per_player_
- estat_game_over_ -> game_over_state_
- continues_usados_ -> continues_used_
Constants:
- MARGE_ESQ/DRET/DALT/BAIX -> MARGIN_LEFT/RIGHT/TOP/BOTTOM
Variables locals i parametres comuns (snake_case):
- nau -> ship, enemic -> enemy, bala -> bullet
- forma -> shape, punt(s) -> point(s)
- jugador -> player, partida -> match
- temps -> time, missatge -> message
Diff: 59 fitxers, +1000/-1000 (simetric). Compila i enllaça.
Pendents per a futures fases (no bloquejants):
- Comentaris de capçalera en catala -> castella
- Variables locals/parametres minoritaris en catala
- Include guards (queden alguns #ifndef en lloc de #pragma once)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
98 lines
3.0 KiB
C++
98 lines
3.0 KiB
C++
// ship_animator.hpp - Sistema d'animació de naus per a l'escena de títol
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
namespace Title {
|
|
|
|
// Estats de l'animació de la ship
|
|
enum class ShipState {
|
|
ENTERING, // Entrant des de fora de pantalla
|
|
FLOATING, // Flotant en posició estàtica
|
|
EXITING // Volant cap al point de fuga
|
|
};
|
|
|
|
// Dades d'una ship individual al títol
|
|
struct TitleShip {
|
|
// Identificació
|
|
int player_id; // 1 o 2
|
|
|
|
// Estat
|
|
ShipState state;
|
|
float state_time; // Temps acumulat en l'state actual
|
|
|
|
// Posicions
|
|
Vec2 initial_position; // Posició d'inici (fora de pantalla per ENTERING)
|
|
Vec2 target_position; // Posició objectiu (rellotge 8 o 4)
|
|
Vec2 current_position; // Posició interpolada actual
|
|
|
|
// Escales (simulació eix Z)
|
|
float initial_scale; // Escala d'inici (més gran = més a prop)
|
|
float target_scale; // Escala objectiu (mida flotació)
|
|
float current_scale; // Escala interpolada actual
|
|
|
|
// Flotació
|
|
float oscillation_phase; // Acumulador de fase per moviment sinusoïdal
|
|
|
|
// Paràmetres d'entrada
|
|
float entry_delay; // Delay abans d'entrar (0.0 per P1, 0.5 per P2)
|
|
|
|
// Paràmetres d'oscil·lació per ship
|
|
float amplitude_x;
|
|
float amplitude_y;
|
|
float frequency_x;
|
|
float frequency_y;
|
|
|
|
// Forma
|
|
std::shared_ptr<Graphics::Shape> shape;
|
|
|
|
// Visibilitat
|
|
bool visible;
|
|
};
|
|
|
|
// Gestor d'animació de naus per a l'escena de títol
|
|
class ShipAnimator {
|
|
public:
|
|
explicit ShipAnimator(SDL_Renderer* renderer);
|
|
|
|
// Cicle de vida
|
|
void init();
|
|
void update(float delta_time);
|
|
void draw() const;
|
|
|
|
// Control d'state (cridat per TitleScene)
|
|
void start_entry_animation();
|
|
void trigger_exit_animation(); // Anima totes les naus
|
|
void trigger_exit_animation_for_player(int player_id); // Anima només una ship (P1=1, P2=2)
|
|
void skip_to_floating_state(); // Salta directament a FLOATING sense animació
|
|
|
|
// Control de visibilitat
|
|
void set_visible(bool visible);
|
|
[[nodiscard]] bool is_animation_complete() const;
|
|
[[nodiscard]] bool is_visible() const; // Comprova si alguna ship és visible
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
std::array<TitleShip, 2> ships_; // Naus P1 i P2
|
|
|
|
// Mètodes d'animació
|
|
void actualitzar_entering(TitleShip& ship, float delta_time);
|
|
void actualitzar_floating(TitleShip& ship, float delta_time);
|
|
void actualitzar_exiting(TitleShip& ship, float delta_time);
|
|
|
|
// Configuració
|
|
void configurar_nau_p1(TitleShip& ship);
|
|
void configurar_nau_p2(TitleShip& ship);
|
|
[[nodiscard]] Vec2 calcular_posicio_fora_pantalla(float angle_rellotge) const;
|
|
};
|
|
|
|
} // namespace Title
|