5871d29d48
Tots els tipus, fitxers, namespace, enums i metodes relacionats amb
les escenes passen del catala a l'angles seguint el .clang-tidy:
Fitxers (renames git):
- source/game/escenes/escena_joc.{hpp,cpp} -> game/scenes/game_scene.{hpp,cpp}
- source/game/escenes/escena_titol.{hpp,cpp} -> game/scenes/title_scene.{hpp,cpp}
- source/game/escenes/escena_logo.{hpp,cpp} -> game/scenes/logo_scene.{hpp,cpp}
- source/core/system/context_escenes.hpp -> core/system/scene_context.hpp
- Carpeta game/escenes/ -> game/scenes/
Tipus (CamelCase):
- EscenaJoc -> GameScene
- EscenaTitol -> TitleScene
- EscenaLogo -> LogoScene
- ContextEscenes -> SceneContext
- Escena (enum class) -> SceneType
- Opcio -> Option
- EstatGameOver -> GameOverState
- EstatTitol -> TitleState
- EstatAnimacio -> AnimationState
- ConfigPartida -> MatchConfig
Namespace:
- GestorEscenes -> SceneManager
Valors d'enum SceneType:
- TITOL -> TITLE
- JOC -> GAME
- EIXIR -> EXIT
(LOGO mantingut)
Metodes (camelBack):
- executar -> run
- canviar_escena -> setNextScene
- escena_desti -> nextScene
- opcio (getter) -> option
- consumir_opcio -> consumeOption
- reset_opcio -> resetOption
- set_config_partida -> setMatchConfig
- get_config_partida -> getMatchConfig
Camps privats (lower_case_):
- escena_desti_ -> next_scene_
- opcio_ -> option_
- config_partida_ -> match_config_
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 nau
|
|
enum class EstatNau {
|
|
ENTERING, // Entrant des de fora de pantalla
|
|
FLOATING, // Flotant en posició estàtica
|
|
EXITING // Volant cap al punt de fuga
|
|
};
|
|
|
|
// Dades d'una nau individual al títol
|
|
struct NauTitol {
|
|
// Identificació
|
|
int jugador_id; // 1 o 2
|
|
|
|
// Estat
|
|
EstatNau estat;
|
|
float temps_estat; // Temps acumulat en l'estat actual
|
|
|
|
// Posicions
|
|
Vec2 posicio_inicial; // Posició d'inici (fora de pantalla per ENTERING)
|
|
Vec2 posicio_objectiu; // Posició objectiu (rellotge 8 o 4)
|
|
Vec2 posicio_actual; // Posició interpolada actual
|
|
|
|
// Escales (simulació eix Z)
|
|
float escala_inicial; // Escala d'inici (més gran = més a prop)
|
|
float escala_objectiu; // Escala objectiu (mida flotació)
|
|
float escala_actual; // Escala interpolada actual
|
|
|
|
// Flotació
|
|
float fase_oscilacio; // 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 nau
|
|
float amplitude_x;
|
|
float amplitude_y;
|
|
float frequency_x;
|
|
float frequency_y;
|
|
|
|
// Forma
|
|
std::shared_ptr<Graphics::Shape> forma;
|
|
|
|
// 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'estat (cridat per TitleScene)
|
|
void start_entry_animation();
|
|
void trigger_exit_animation(); // Anima totes les naus
|
|
void trigger_exit_animation_for_player(int jugador_id); // Anima només una nau (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 nau és visible
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
std::array<NauTitol, 2> naus_; // Naus P1 i P2
|
|
|
|
// Mètodes d'animació
|
|
void actualitzar_entering(NauTitol& nau, float delta_time);
|
|
void actualitzar_floating(NauTitol& nau, float delta_time);
|
|
void actualitzar_exiting(NauTitol& nau, float delta_time);
|
|
|
|
// Configuració
|
|
void configurar_nau_p1(NauTitol& nau);
|
|
void configurar_nau_p2(NauTitol& nau);
|
|
[[nodiscard]] Vec2 calcular_posicio_fora_pantalla(float angle_rellotge) const;
|
|
};
|
|
|
|
} // namespace Title
|