efbf2457a1
Primera tanda mecánica sobre el lint pendiente. Arregla la causa raíz, no
silencia diagnósticos. Detalle por categoría:
- Uninit members (cppcheck warnings) → inicializadores en declaración:
Bullet (esta_, owner_id_, grace_timer_), Enemy (drotacio_, rotacio_,
esta_, type_, tracking_timer_, ship_position_, tracking_strength_,
direction_change_timer_, timer_invulnerabilitat_), Ship (is_hit_,
invulnerable_timer_), Shape (escala_defecte_) y TitleShip (todos los
miembros del struct, que viven dentro de un std::array<,2>).
- returnByReference (cppcheck performance) → return const T&:
Shape::getName, ResourceLoader::getBasePath. De paso, Shape::get_nom
se renombra a getName y get_num_primitives a getNumPrimitives para
cumplir la convención camelBack del proyecto (lint del .clang-tidy).
- useInitializationList (cppcheck performance) →
Starfield::shape_estrella_ pasa a la lista de inicialización (reordenada
según la declaración para no disparar -Wreorder-ctor).
- noExplicitConstructor (cppcheck style) → explicit en ctores de 1 arg:
Bullet(Renderer*), Enemy(Renderer*), Ship(Renderer*,...) y VectorText(Renderer*).
- variableScope (cppcheck style) → en vector_text.cpp se elimina la
variable 'c' intermedia y se usa el literal '\\xA9' directamente en el
único punto donde se necesita.
- constParameterReference (cppcheck style) → drawScoreboardAnimated pasa
el VectorText por const ref (la API render/renderCentered es const).
- Warnings preexistentes del compilador (resueltos de paso):
- stage_config.hpp: stage_id <= 255 sobre uint8_t era siempre true; se
elimina la comparación redundante y se explica con comentario.
- director.cpp: 'struct stat st = {.st_dev = 0};' disparaba
-Wmissing-field-initializers; pasa a 'struct stat st{};' (zero-init
completo, robusto a las variantes específicas del SO).
- game_scene.cpp: stepDeathSequence devolvía un bool [[nodiscard]] que
el caller ignoraba; el valor era puramente interno. Cambiada la
firma a void.
- cppcheck: añadido --suppress=useStlAlgorithm. Las 26 sugerencias
'Consider using std::any_of/find_if/count_if' son cosméticas y no
aportan claridad sobre las raw loops actuales.
- .clang-tidy de source/core/audio/ eliminado: deshabilitaba todos los
checks en ese subdirectorio por dependencia de jail_audio.hpp, pero
impedía ejecutar 'make tidy' (clang-tidy aborta con "no checks
enabled" al primer archivo del directorio). El proyecto pasa a usar
el mismo patrón de CCAE: solo source/external/ y source/legacy/
quedan fuera del lint.
- lint-reports/ añadido a .gitignore. Carpeta donde 'make tidy' y
'make cppcheck' vuelcan su salida completa para inspección posterior.
Build limpio, cero warnings activos.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
103 lines
3.4 KiB
C++
103 lines
3.4 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 <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
namespace Title {
|
|
|
|
// Estats de l'animación de la ship
|
|
enum class ShipState {
|
|
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]] bool is_animation_complete() const;
|
|
[[nodiscard]] bool is_visible() const; // 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 actualitzar_entering(TitleShip& ship, float delta_time);
|
|
void actualitzar_floating(TitleShip& ship, float delta_time);
|
|
void actualitzar_exiting(TitleShip& ship, float delta_time);
|
|
|
|
// Configuración
|
|
void configurar_nau_p1(TitleShip& ship);
|
|
void configurar_nau_p2(TitleShip& ship);
|
|
[[nodiscard]] Vec2 calcular_posicio_fora_pantalla(float angle_rellotge) const;
|
|
};
|
|
|
|
} // namespace Title
|