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>
96 lines
4.2 KiB
C++
96 lines
4.2 KiB
C++
// logo_scene.hpp - Pantalla de start del juego
|
|
// Muestra logo JAILGAMES animat con zoom i salta al juego
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "core/defaults.hpp"
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/input/input_types.hpp"
|
|
#include "core/rendering/sdl_manager.hpp"
|
|
#include "core/system/scene.hpp"
|
|
#include "core/system/scene_context.hpp"
|
|
#include "core/types.hpp"
|
|
#include "game/effects/debris_manager.hpp"
|
|
|
|
class LogoScene final : public Scene {
|
|
public:
|
|
explicit LogoScene(SDLManager& sdl, SceneManager::SceneContext& context);
|
|
~LogoScene() override; // Destructor per aturar sons
|
|
|
|
// Scene interface
|
|
void handleEvent(const SDL_Event& event) override;
|
|
void update(float delta_time) override;
|
|
void draw() override;
|
|
[[nodiscard]] auto isFinished() const -> bool override;
|
|
|
|
private:
|
|
// Màquina de estats per l'animación
|
|
enum class AnimationState : std::uint8_t {
|
|
PRE_ANIMATION, // Pantalla negra inicial
|
|
ANIMATION, // Animación de zoom de lletres
|
|
POST_ANIMATION, // Logo complet visible
|
|
EXPLOSION, // Explosión seqüencial de lletres
|
|
POST_EXPLOSION // Espera después de l'última explosión
|
|
};
|
|
|
|
SDLManager& sdl_;
|
|
SceneManager::SceneContext& context_;
|
|
AnimationState estat_actual_{AnimationState::PRE_ANIMATION}; // Estat actual de la màquina
|
|
float
|
|
temps_estat_actual_{0.0F}; // Temps en l'state actual (reset en cada transición)
|
|
|
|
// Gestor de fragments de explosions
|
|
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
|
|
|
// Seguiment de explosions seqüencials
|
|
size_t lletra_explosio_index_{0}; // Índex de la següent lletra a explode
|
|
float temps_des_ultima_explosio_{0.0F}; // Temps desde l'última explosión
|
|
std::vector<size_t> ordre_explosio_; // Ordre aleatori de índexs de lletres
|
|
|
|
// Estructura para cada lletra del logo
|
|
struct LetraLogo {
|
|
std::shared_ptr<Graphics::Shape> shape;
|
|
Vec2 position; // Posición final en pantalla
|
|
float ancho; // Ancho del bounding box
|
|
float offset_centre; // Distancia de min_x a shape_centre.x
|
|
};
|
|
|
|
std::vector<LetraLogo> lletres_; // 9 lletres: J-A-I-L-G-A-M-E-S
|
|
|
|
// Seguiment de sons de lletres (evitar reproduccions repetides)
|
|
std::array<bool, 9> so_reproduit_; // Track si cada lletra ya ha reproduit el so
|
|
|
|
// Constants de animación
|
|
static constexpr float DURACIO_PRE = 1.5F; // Duració PRE_ANIMATION (pantalla negra)
|
|
static constexpr float DURACIO_ZOOM = 4.0F; // Duració del zoom (segons)
|
|
static constexpr float DURACIO_POST_ANIMATION = 3.0F; // Duració POST_ANIMATION (logo complet)
|
|
static constexpr float DURACIO_POST_EXPLOSION = 3.0F; // Duració POST_EXPLOSION (espera final)
|
|
static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1F; // Temps entre explosions de lletres
|
|
static constexpr float VELOCITAT_EXPLOSIO = 240.0F; // Velocidad base fragments (px/s)
|
|
static constexpr float ESCALA_INICIAL = 0.1F; // Escala inicial (10%)
|
|
static constexpr float ESCALA_FINAL = 0.8F; // Escala final (80%)
|
|
static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espaiat entre lletres
|
|
|
|
// Constants de animación seqüencial
|
|
static constexpr float THRESHOLD_LETRA = 0.6F; // Umbral per activar següent lletra (0.0-1.0)
|
|
static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5F; // Vec2 inicial X del zoom
|
|
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4F; // Vec2 inicial Y del zoom
|
|
|
|
// Métodos privats
|
|
void initLetters();
|
|
void updateExplosions(float delta_time);
|
|
auto checkSkipButtonPressed() -> bool;
|
|
|
|
// Métodos de gestió de estats
|
|
void changeState(AnimationState nou_estat);
|
|
[[nodiscard]] auto allLettersComplete() const -> bool;
|
|
};
|