fa7da4ca58
El runtime de rendering pasa a SDL3 GPU. SDL_Renderer eliminado por completo del proyecto: SDLManager posee un GpuFrameRenderer y todo el resto del codigo habla con un Rendering::Renderer* opaco (alias del GpuFrameRenderer). Cambios principales: - core/rendering/render_context.hpp: alias central `using Rendering::Renderer = GPU::GpuFrameRenderer;` — punto unico de indireccion entre el juego y el backend de dibujo. - core/rendering/sdl_manager.hpp/cpp: deja de tener SDL_Renderer*; contiene un Rendering::Renderer gpu_renderer_. iniciar() ahora hace GpuDevice::init + pipeline; clear() llama beginFrame; present() llama endFrame. Letterbox se aplica via setViewport tras cada begin del render pass. toggleVSync() usa SDL_SetGPUSwapchainParameters. - core/rendering/line_renderer.hpp/cpp: la firma cambia a `linea(Renderer*, x1,y1,x2,y2, brightness, thickness)`. La implementacion deja de usar SDL_RenderLine: empuja la linea como quad extrudido al batch del GpuFrameRenderer. Se anade un grosor global configurable via setLineThickness (default 1.5 px). Ya no se aplica transform_x/y porque el shader hace logical->NDC y el viewport hace el letterbox. - gpu_frame_renderer: anade setViewport (aplicable mid-frame), setVSync (PRESENTMODE_VSYNC/IMMEDIATE) y applyViewport interno que re-aplica el viewport tras reabrir el render pass en flushBatch. - Sed sweep masivo en 19 archivos: SDL_Renderer* -> Rendering::Renderer* en headers y .cpp de entities, effects, graphics y title. Los archivos solo propagan el puntero — solo line_renderer consume sus metodos. SDL_Renderer queda eliminado del proyecto. Smoke test xvfb: backend Vulkan detectado, binario arranca, carga todos los shapes/audio/title, TitleScene inicializa, termina limpio con "Adeu!". stderr vacio. Validacion visual pendiente en hardware real (xvfb VMware sin 3D no muestra el swapchain Vulkan). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
100 lines
3.1 KiB
C++
100 lines
3.1 KiB
C++
// ship_animator.hpp - Sistema de animación de naves para l'escena de título
|
|
// © 2025 Port a C++20 con SDL3
|
|
|
|
#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
|
|
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ó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; // Escala de start (més grande = més a prop)
|
|
float target_scale; // Escala objetivo (mida flotació)
|
|
float current_scale; // Escala interpolada actual
|
|
|
|
// Flotació
|
|
float oscillation_phase; // Acumulador de fase per movement sinusoïdal
|
|
|
|
// Parámetros de entrada
|
|
float entry_delay; // Delay antes de entrar (0.0 per P1, 0.5 per P2)
|
|
|
|
// Parámetros de 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 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
|