6d0df85e5e
Tanda grande de identifier-naming: 47 métodos privados pasan de snake_case (en su mayoría catalán/spanish) a camelBack inglés. Solo afecta a sus archivos hpp+cpp; ningún símbolo cruza fichero (los públicos quedan para una pasada manual con VS Code). Renames por clase: - ShapeLoader: resolve_path → resolvePath. - VectorText: load_charset → loadCharset, get_shape_filename → getShapeFilename. - Shape: starts_with → startsWith (cuidado de no tocar std::string::starts_with que también usaba), extract_value → extractValue, parse_center → parseCenter, parse_points → parsePoints. - Starfield: inicialitzar_estrella → initStar, fora_area → isOutsideArea, calcular_escala → computeScale, calcular_brightness → computeBrightness. - TitleScene: actualitzar_animacio_logo → updateLogoAnimation, inicialitzar_titol → initTitle. - LogoScene: inicialitzar_lletres → initLetters, actualitzar_explosions → updateExplosions, canviar_estat → changeState, totes_lletres_completes → allLettersComplete. - SpawnController: generar_spawn_events → generateSpawnEvents, seleccionar_tipus_aleatori → selectRandomType, spawn_enemic → spawnEnemy, aplicar_multiplicadors → applyMultipliers. - ShipAnimator: actualitzar_entering/floating/exiting → updateEntering/Floating/Exiting, configurar_nau_p1/p2 → configureShipP1/P2, calcular_posicio_fora_pantalla → computeOffscreenPosition. - GameScene: dibuixar_marges → drawMargins, dibuixar_marcador → drawScoreboard, disparar_bala → fireBullet, obtenir_punt_spawn → getSpawnPoint, unir_jugador → joinPlayer, dibuixar_continue → drawContinue, dibuixar_missatge_stage → drawStageMessage. - StageLoader: parse_metadata/stage/spawn_config/distribution/multipliers/ spawn_mode → parseMetadata/Stage/SpawnConfig/Distribution/Multipliers/ SpawnMode, validar_config → validateConfig. - StageManager: canviar_estat → changeState, processar_init_hud/level_start/playing/level_completed → processInitHud/LevelStart/Playing/LevelCompleted, carregar_stage → loadStage. Métodos públicos y funciones libres (cross-file) quedan a propósito sin tocar — los renombrará el usuario con la herramienta de rename de VS Code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
104 lines
3.5 KiB
C++
104 lines
3.5 KiB
C++
// ship_animator.hpp - Sistema de animación de naves para l'escena de título
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
|
|
#include "core/rendering/render_context.hpp"
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
namespace Title {
|
|
|
|
// Estats de l'animación de la ship
|
|
enum class ShipState : std::uint8_t {
|
|
ENTERING, // Entrant desde fuera de pantalla
|
|
FLOATING, // Flotante en posición estàtica
|
|
EXITING // Volant hacia el point de fuga
|
|
};
|
|
|
|
// Dades de una ship individual al título.
|
|
// Todos los miembros tienen inicializador por defecto: ShipAnimator::ships_
|
|
// es un std::array<TitleShip, 2> y sin estos defaults los campos primitivos
|
|
// quedarían indeterminados al instanciar el animador.
|
|
struct TitleShip {
|
|
// Identificació
|
|
int player_id{0}; // 1 o 2
|
|
|
|
// Estat
|
|
ShipState state{ShipState::ENTERING};
|
|
float state_time{0.0F}; // Temps acumulat en l'state actual
|
|
|
|
// Posicions
|
|
Vec2 initial_position{}; // Posición de start (fuera de pantalla per ENTERING)
|
|
Vec2 target_position{}; // Posición objetivo (rellotge 8 o 4)
|
|
Vec2 current_position{}; // Posición interpolada actual
|
|
|
|
// Escales (simulació eix Z)
|
|
float initial_scale{1.0F}; // Escala de start (més grande = més a prop)
|
|
float target_scale{1.0F}; // Escala objetivo (mida flotació)
|
|
float current_scale{1.0F}; // Escala interpolada actual
|
|
|
|
// Flotació
|
|
float oscillation_phase{0.0F}; // Acumulador de fase per movement sinusoïdal
|
|
|
|
// Parámetros de entrada
|
|
float entry_delay{0.0F}; // Delay antes de entrar (0.0 per P1, 0.5 per P2)
|
|
|
|
// Parámetros de oscil·lació per ship
|
|
float amplitude_x{0.0F};
|
|
float amplitude_y{0.0F};
|
|
float frequency_x{0.0F};
|
|
float frequency_y{0.0F};
|
|
|
|
// Forma
|
|
std::shared_ptr<Graphics::Shape> shape;
|
|
|
|
// Visibilitat
|
|
bool visible{false};
|
|
};
|
|
|
|
// Gestor de animación de naves para l'escena de título
|
|
class ShipAnimator {
|
|
public:
|
|
explicit ShipAnimator(Rendering::Renderer* renderer);
|
|
|
|
// Cicle de vida
|
|
void init();
|
|
void update(float delta_time);
|
|
void draw() const;
|
|
|
|
// Control de state (cridat per TitleScene)
|
|
void start_entry_animation();
|
|
void trigger_exit_animation(); // Anima todas las naves
|
|
void trigger_exit_animation_for_player(int player_id); // Anima solo una ship (P1=1, P2=2)
|
|
void skip_to_floating_state(); // Salta directament a FLOATING sin animación
|
|
|
|
// Control de visibilitat
|
|
void set_visible(bool visible);
|
|
[[nodiscard]] auto is_animation_complete() const -> bool;
|
|
[[nodiscard]] auto is_visible() const -> bool; // Comprova si alguna ship es visible
|
|
|
|
private:
|
|
Rendering::Renderer* renderer_;
|
|
std::array<TitleShip, 2> ships_; // Naves P1 i P2
|
|
|
|
// Métodos de animación
|
|
void updateEntering(TitleShip& ship, float delta_time);
|
|
void updateFloating(TitleShip& ship, float delta_time);
|
|
void updateExiting(TitleShip& ship, float delta_time);
|
|
|
|
// Configuración
|
|
void configureShipP1(TitleShip& ship);
|
|
void configureShipP2(TitleShip& ship);
|
|
[[nodiscard]] auto computeOffscreenPosition(float angle_rellotge) const -> Vec2;
|
|
};
|
|
|
|
} // namespace Title
|