LOGO explota

This commit is contained in:
2025-12-02 08:50:38 +01:00
parent 73f222fcb7
commit 20538af4c6
22 changed files with 1754 additions and 1598 deletions

21
.clang-format Normal file
View File

@@ -0,0 +1,21 @@
BasedOnStyle: Google
IndentWidth: 4
IndentAccessModifiers: true
ColumnLimit: 0 # Sin límite de longitud de línea
BreakBeforeBraces: Attach # Llaves en la misma línea
AllowShortIfStatementsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlignOperands: DontAlign
AlignAfterOpenBracket: DontAlign
BinPackArguments: false
BinPackParameters: false
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 4
IndentWrappedFunctionNames: false
Cpp11BracedListStyle: true
BreakConstructorInitializers: BeforeColon
AllowAllConstructorInitializersOnNextLine: false
PackConstructorInitializers: Never
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false

View File

@@ -2,19 +2,24 @@
// © 2025 Port a C++20 amb SDL3
#include "sdl_manager.hpp"
#include "core/defaults.hpp"
#include "core/rendering/line_renderer.hpp"
#include "game/options.hpp"
#include "project.h"
#include <algorithm>
#include <format>
#include <iostream>
#include "core/defaults.hpp"
#include "core/rendering/line_renderer.hpp"
#include "game/options.hpp"
#include "project.h"
SDLManager::SDLManager()
: finestra_(nullptr), renderer_(nullptr),
: finestra_(nullptr),
renderer_(nullptr),
current_width_(Defaults::Window::WIDTH),
current_height_(Defaults::Window::HEIGHT), is_fullscreen_(false),
max_width_(1920), max_height_(1080) {
current_height_(Defaults::Window::HEIGHT),
is_fullscreen_(false),
max_width_(1920),
max_height_(1080) {
// Inicialitzar SDL3
if (!SDL_Init(SDL_INIT_VIDEO)) {
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << std::endl;
@@ -25,8 +30,7 @@ SDLManager::SDLManager()
calculateMaxWindowSize();
// Construir títol dinàmic igual que en pollo
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME,
Project::VERSION, Project::COPYRIGHT);
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME, Project::VERSION, Project::COPYRIGHT);
// Crear finestra CENTRADA (SDL ho fa automàticament amb CENTERED)
finestra_ =
@@ -41,8 +45,7 @@ SDLManager::SDLManager()
}
// IMPORTANT: Centrar explícitament la finestra
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED);
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
// Crear renderer amb acceleració
renderer_ = SDL_CreateRenderer(finestra_, nullptr);
@@ -64,8 +67,12 @@ SDLManager::SDLManager()
// Constructor amb configuració
SDLManager::SDLManager(int width, int height, bool fullscreen)
: finestra_(nullptr), renderer_(nullptr), current_width_(width),
current_height_(height), is_fullscreen_(fullscreen), max_width_(1920),
: finestra_(nullptr),
renderer_(nullptr),
current_width_(width),
current_height_(height),
is_fullscreen_(fullscreen),
max_width_(1920),
max_height_(1080) {
// Inicialitzar SDL3
if (!SDL_Init(SDL_INIT_VIDEO)) {
@@ -77,8 +84,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
calculateMaxWindowSize();
// Construir títol dinàmic
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME,
Project::VERSION, Project::COPYRIGHT);
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME, Project::VERSION, Project::COPYRIGHT);
// Configurar flags de la finestra
SDL_WindowFlags flags = SDL_WINDOW_RESIZABLE;
@@ -87,8 +93,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
}
// Crear finestra
finestra_ = SDL_CreateWindow(window_title.c_str(), current_width_,
current_height_, flags);
finestra_ = SDL_CreateWindow(window_title.c_str(), current_width_, current_height_, flags);
if (!finestra_) {
std::cerr << "Error creant finestra: " << SDL_GetError() << std::endl;
@@ -98,8 +103,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
// Centrar explícitament la finestra (si no és fullscreen)
if (!is_fullscreen_) {
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED);
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
// Crear renderer amb acceleració

View File

@@ -4,10 +4,12 @@
#ifndef SDL_MANAGER_HPP
#define SDL_MANAGER_HPP
#include "core/rendering/color_oscillator.hpp"
#include <SDL3/SDL.h>
#include <cstdint>
#include "core/rendering/color_oscillator.hpp"
class SDLManager {
public:
SDLManager(); // Constructor per defecte (usa Defaults::)

2
source/external/.clang-format vendored Normal file
View File

@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: Never

View File

@@ -32,8 +32,7 @@ inline bool dins_zona_joc(float x, float y) {
return SDL_PointInRectFloat(&punt, &Defaults::Zones::PLAYAREA);
}
inline void obtenir_limits_zona(float &min_x, float &max_x, float &min_y,
float &max_y) {
inline void obtenir_limits_zona(float& min_x, float& max_x, float& min_y, float& max_y) {
const auto& zona = Defaults::Zones::PLAYAREA;
min_x = zona.x;
max_x = zona.x + zona.w;

View File

@@ -2,18 +2,19 @@
// © 2025 Port a C++20 amb SDL3
#include "debris_manager.hpp"
#include "core/defaults.hpp"
#include "core/rendering/line_renderer.hpp"
#include <cmath>
#include <cstdlib>
#include <iostream>
#include "core/defaults.hpp"
#include "core/rendering/line_renderer.hpp"
namespace Effects {
// Helper: transformar punt amb rotació, escala i trasllació
// (Copiat de shape_renderer.cpp:12-34)
static Punt transform_point(const Punt &point, const Punt &shape_centre,
const Punt &posicio, float angle, float escala) {
static Punt transform_point(const Punt& point, const Punt& shape_centre, const Punt& posicio, float angle, float escala) {
// 1. Centrar el punt respecte al centre de la forma
float centered_x = point.x - shape_centre.x;
float centered_y = point.y - shape_centre.y;
@@ -33,7 +34,8 @@ static Punt transform_point(const Punt &point, const Punt &shape_centre,
return {rotated_x + posicio.x, rotated_y + posicio.y};
}
DebrisManager::DebrisManager(SDL_Renderer *renderer) : renderer_(renderer) {
DebrisManager::DebrisManager(SDL_Renderer* renderer)
: renderer_(renderer) {
// Inicialitzar tots els debris com inactius
for (auto& debris : debris_pool_) {
debris.actiu = false;
@@ -41,7 +43,9 @@ DebrisManager::DebrisManager(SDL_Renderer *renderer) : renderer_(renderer) {
}
void DebrisManager::explotar(const std::shared_ptr<Graphics::Shape>& shape,
const Punt &centre, float angle, float escala,
const Punt& centre,
float angle,
float escala,
float velocitat_base) {
if (!shape || !shape->es_valida()) {
return;
@@ -199,10 +203,7 @@ void DebrisManager::dibuixar() const {
continue;
// Dibuixar segment de línia
Rendering::linea(renderer_, static_cast<int>(debris.p1.x),
static_cast<int>(debris.p1.y),
static_cast<int>(debris.p2.x),
static_cast<int>(debris.p2.y), true);
Rendering::linea(renderer_, static_cast<int>(debris.p1.x), static_cast<int>(debris.p1.y), static_cast<int>(debris.p2.x), static_cast<int>(debris.p2.y), true);
}
}

View File

@@ -2,13 +2,15 @@
// © 2025 Port a C++20 amb SDL3
#pragma once
#include "debris.hpp"
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
#include <SDL3/SDL.h>
#include <array>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
#include "debris.hpp"
namespace Effects {
// Gestor de fragments d'explosions
@@ -24,7 +26,9 @@ public:
// - escala: escala de l'objecte (1.0 = normal)
// - velocitat_base: velocitat inicial dels fragments (px/s)
void explotar(const std::shared_ptr<Graphics::Shape>& shape,
const Punt &centre, float angle, float escala,
const Punt& centre,
float angle,
float escala,
float velocitat_base);
// Actualitzar tots els fragments actius

View File

@@ -3,16 +3,20 @@
// © 2025 Port a C++20 amb SDL3
#include "game/entities/bala.hpp"
#include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp"
#include <cmath>
#include <iostream>
Bala::Bala(SDL_Renderer *renderer)
: renderer_(renderer), centre_({0.0f, 0.0f}), angle_(0.0f),
velocitat_(0.0f), esta_(false) {
#include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp"
Bala::Bala(SDL_Renderer* renderer)
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
esta_(false) {
// [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("bullet.shp");

View File

@@ -3,14 +3,17 @@
// © 2025 Port a C++20 amb SDL3
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
#include <SDL3/SDL.h>
#include <memory>
class Bala {
public:
Bala() : renderer_(nullptr) {}
Bala()
: renderer_(nullptr) {}
Bala(SDL_Renderer* renderer);
void inicialitzar();

View File

@@ -3,17 +3,23 @@
// © 2025 Port a C++20 amb SDL3
#include "game/entities/enemic.hpp"
#include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp"
#include <cmath>
#include <cstdlib>
#include <iostream>
Enemic::Enemic(SDL_Renderer *renderer)
: renderer_(renderer), centre_({0.0f, 0.0f}), angle_(0.0f),
velocitat_(0.0f), drotacio_(0.0f), rotacio_(0.0f), esta_(false) {
#include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp"
Enemic::Enemic(SDL_Renderer* renderer)
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
drotacio_(0.0f),
rotacio_(0.0f),
esta_(false) {
// [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("enemy_pentagon.shp");

View File

@@ -3,14 +3,17 @@
// © 2025 Port a C++20 amb SDL3
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
#include <SDL3/SDL.h>
#include <memory>
class Enemic {
public:
Enemic() : renderer_(nullptr) {}
Enemic()
: renderer_(nullptr) {}
Enemic(SDL_Renderer* renderer);
void inicialitzar();

View File

@@ -3,18 +3,23 @@
// © 2025 Port a C++20 amb SDL3
#include "game/entities/nau.hpp"
#include <SDL3/SDL.h>
#include <cmath>
#include <iostream>
#include "core/defaults.hpp"
#include "core/graphics/shape_loader.hpp"
#include "core/rendering/shape_renderer.hpp"
#include "game/constants.hpp"
#include <SDL3/SDL.h>
#include <cmath>
#include <iostream>
Nau::Nau(SDL_Renderer* renderer)
: renderer_(renderer), centre_({0.0f, 0.0f}), angle_(0.0f),
velocitat_(0.0f), esta_tocada_(false) {
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
esta_tocada_(false) {
// [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("ship.shp");

View File

@@ -3,14 +3,17 @@
// © 2025 Port a C++20 amb SDL3
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
#include <SDL3/SDL.h>
#include <memory>
class Nau {
public:
Nau() : renderer_(nullptr) {}
Nau()
: renderer_(nullptr) {}
Nau(SDL_Renderer* renderer);
void inicialitzar();

View File

@@ -3,18 +3,23 @@
// © 2025 Port a C++20 amb SDL3
#include "escena_joc.hpp"
#include "../../core/rendering/line_renderer.hpp"
#include "../../core/system/gestor_escenes.hpp"
#include "../../core/system/global_events.hpp"
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>
#include "../../core/rendering/line_renderer.hpp"
#include "../../core/system/gestor_escenes.hpp"
#include "../../core/system/global_events.hpp"
EscenaJoc::EscenaJoc(SDLManager& sdl)
: sdl_(sdl), debris_manager_(sdl.obte_renderer()),
nau_(sdl.obte_renderer()), itocado_(0), text_(sdl.obte_renderer()) {
: sdl_(sdl),
debris_manager_(sdl.obte_renderer()),
nau_(sdl.obte_renderer()),
itocado_(0),
text_(sdl.obte_renderer()) {
// Inicialitzar bales amb renderer
for (auto& bala : bales_) {
bala = Bala(sdl.obte_renderer());

View File

@@ -5,17 +5,19 @@
#ifndef ESCENA_JOC_HPP
#define ESCENA_JOC_HPP
#include <SDL3/SDL.h>
#include <array>
#include <cstdint>
#include "../../core/graphics/vector_text.hpp"
#include "../../core/rendering/sdl_manager.hpp"
#include "../effects/debris_manager.hpp"
#include "../../core/types.hpp"
#include "../constants.hpp"
#include "../effects/debris_manager.hpp"
#include "../entities/bala.hpp"
#include "../entities/enemic.hpp"
#include "../entities/nau.hpp"
#include <SDL3/SDL.h>
#include <array>
#include <cstdint>
// Classe principal del joc (escena)
class EscenaJoc {

View File

@@ -2,18 +2,19 @@
// © 2025 Port a C++20
#include "escena_logo.hpp"
#include "../../core/graphics/shape_loader.hpp"
#include "../../core/rendering/shape_renderer.hpp"
#include "../../core/system/gestor_escenes.hpp"
#include "../../core/system/global_events.hpp"
#include <algorithm>
#include <cfloat>
#include <iostream>
#include "../../core/graphics/shape_loader.hpp"
#include "../../core/rendering/shape_renderer.hpp"
#include "../../core/system/gestor_escenes.hpp"
#include "../../core/system/global_events.hpp"
// Helper: calcular el progrés individual d'una lletra
// en funció del progrés global (efecte seqüencial)
static float calcular_progress_letra(size_t letra_index, size_t num_letras,
float global_progress, float threshold) {
static float calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) {
if (num_letras == 0)
return 1.0f;
@@ -34,8 +35,12 @@ static float calcular_progress_letra(size_t letra_index, size_t num_letras,
}
EscenaLogo::EscenaLogo(SDLManager& sdl)
: sdl_(sdl), estat_actual_(EstatAnimacio::PRE_ANIMATION),
temps_estat_actual_(0.0f) {
: sdl_(sdl),
estat_actual_(EstatAnimacio::PRE_ANIMATION),
temps_estat_actual_(0.0f),
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.obte_renderer())),
lletra_explosio_index_(0),
temps_des_ultima_explosio_(0.0f) {
std::cout << "Escena Logo: Inicialitzant...\n";
inicialitzar_lletres();
}
@@ -89,9 +94,15 @@ void EscenaLogo::inicialitzar_lletres() {
// Llista de fitxers .shp (A repetida per a les dues A's)
std::vector<std::string> fitxers = {
"logo/letra_j.shp", "logo/letra_a.shp", "logo/letra_i.shp",
"logo/letra_l.shp", "logo/letra_g.shp", "logo/letra_a.shp",
"logo/letra_m.shp", "logo/letra_e.shp", "logo/letra_s.shp"};
"logo/letra_j.shp",
"logo/letra_a.shp",
"logo/letra_i.shp",
"logo/letra_l.shp",
"logo/letra_g.shp",
"logo/letra_a.shp",
"logo/letra_m.shp",
"logo/letra_e.shp",
"logo/letra_s.shp"};
// Pas 1: Carregar totes les formes i calcular amplades
float ancho_total = 0.0f;
@@ -160,6 +171,13 @@ void EscenaLogo::inicialitzar_lletres() {
void EscenaLogo::canviar_estat(EstatAnimacio nou_estat) {
estat_actual_ = nou_estat;
temps_estat_actual_ = 0.0f; // Reset temps
// Inicialitzar estat d'explosió
if (nou_estat == EstatAnimacio::EXPLOSION) {
lletra_explosio_index_ = 0;
temps_des_ultima_explosio_ = 0.0f;
}
std::cout << "[EscenaLogo] Canvi a estat: " << static_cast<int>(nou_estat)
<< "\n";
}
@@ -169,6 +187,35 @@ bool EscenaLogo::totes_lletres_completes() const {
return temps_estat_actual_ >= DURACIO_ZOOM;
}
void EscenaLogo::actualitzar_explosions(float delta_time) {
temps_des_ultima_explosio_ += delta_time;
// Comprovar si és el moment d'explotar la següent lletra
if (temps_des_ultima_explosio_ >= DELAY_ENTRE_EXPLOSIONS) {
if (lletra_explosio_index_ < lletres_.size()) {
// Explotar lletra actual
const auto& lletra = lletres_[lletra_explosio_index_];
debris_manager_->explotar(
lletra.forma, // Forma a explotar
lletra.posicio, // Posició
0.0f, // Angle (sense rotació)
ESCALA_FINAL, // Escala (lletres a escala final)
VELOCITAT_EXPLOSIO // Velocitat base
);
std::cout << "[EscenaLogo] Explota lletra " << lletra_explosio_index_ << "\n";
// Passar a la següent lletra
lletra_explosio_index_++;
temps_des_ultima_explosio_ = 0.0f;
} else {
// Totes les lletres han explotat, transició a POST_EXPLOSION
canviar_estat(EstatAnimacio::POST_EXPLOSION);
}
}
}
void EscenaLogo::actualitzar(float delta_time) {
temps_estat_actual_ += delta_time;
@@ -186,11 +233,24 @@ void EscenaLogo::actualitzar(float delta_time) {
break;
case EstatAnimacio::POST_ANIMATION:
if (temps_estat_actual_ >= DURACIO_POST) {
if (temps_estat_actual_ >= DURACIO_POST_ANIMATION) {
canviar_estat(EstatAnimacio::EXPLOSION);
}
break;
case EstatAnimacio::EXPLOSION:
actualitzar_explosions(delta_time);
break;
case EstatAnimacio::POST_EXPLOSION:
if (temps_estat_actual_ >= DURACIO_POST_EXPLOSION) {
GestorEscenes::actual = GestorEscenes::Escena::JOC;
}
break;
}
// Actualitzar animacions de debris
debris_manager_->actualitzar(delta_time);
}
void EscenaLogo::dibuixar() {
@@ -203,53 +263,71 @@ void EscenaLogo::dibuixar() {
return; // No renderitzar lletres
}
// ANIMATION o POST_ANIMATION: Calcular progrés
// ANIMATION o POST_ANIMATION: Dibuixar lletres amb animació
if (estat_actual_ == EstatAnimacio::ANIMATION ||
estat_actual_ == EstatAnimacio::POST_ANIMATION) {
float global_progress =
(estat_actual_ == EstatAnimacio::ANIMATION)
? std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f)
: 1.0f; // POST: mantenir al 100%
// Punt inicial del zoom (configurable amb ORIGEN_ZOOM_X/Y)
const Punt ORIGEN_ZOOM = {ORIGEN_ZOOM_X, ORIGEN_ZOOM_Y};
// Dibuixar cada lletra amb animació seqüencial
for (size_t i = 0; i < lletres_.size(); i++) {
const auto& lletra = lletres_[i];
// Calcular progrés individual d'aquesta lletra (0.0 → 1.0)
float letra_progress = calcular_progress_letra(
i, lletres_.size(), global_progress, THRESHOLD_LETRA);
i,
lletres_.size(),
global_progress,
THRESHOLD_LETRA);
// Si la lletra encara no ha començat, saltar-la
if (letra_progress <= 0.0f) {
continue;
}
// Interpolar posició: des del origen zoom cap a posició final
Punt pos_actual;
pos_actual.x =
ORIGEN_ZOOM.x + (lletra.posicio.x - ORIGEN_ZOOM.x) * letra_progress;
pos_actual.y =
ORIGEN_ZOOM.y + (lletra.posicio.y - ORIGEN_ZOOM.y) * letra_progress;
// Aplicar ease-out quadràtic per suavitat
float t = letra_progress;
float ease_factor = 1.0f - (1.0f - t) * (1.0f - t);
// Interpolar escala amb ease-out: des de ESCALA_INICIAL cap a ESCALA_FINAL
float escala_actual =
ESCALA_INICIAL + (ESCALA_FINAL - ESCALA_INICIAL) * ease_factor;
// Renderitzar la lletra
Rendering::render_shape(
sdl_.obte_renderer(), lletra.forma,
pos_actual, // Posició interpolada
0.0f, // Sense rotació
escala_actual, // Escala interpolada amb ease-out
true, // Dibuixar
1.0f // Progress = 1.0 (lletra completa, sense animació de primitives)
);
sdl_.obte_renderer(),
lletra.forma,
pos_actual,
0.0f,
escala_actual,
true,
1.0f);
}
}
// EXPLOSION: Dibuixar només lletres que encara no han explotat
if (estat_actual_ == EstatAnimacio::EXPLOSION) {
for (size_t i = lletra_explosio_index_; i < lletres_.size(); i++) {
const auto& lletra = lletres_[i];
Rendering::render_shape(
sdl_.obte_renderer(),
lletra.forma,
lletra.posicio,
0.0f,
ESCALA_FINAL,
true,
1.0f);
}
}
// POST_EXPLOSION: No dibuixar lletres, només debris (a baix)
// Sempre dibuixar debris (si n'hi ha d'actius)
debris_manager_->dibuixar();
sdl_.presenta();
}

View File

@@ -4,12 +4,15 @@
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include <vector>
#include "../../core/graphics/shape.hpp"
#include "../../core/rendering/sdl_manager.hpp"
#include "../../core/types.hpp"
#include <SDL3/SDL.h>
#include <memory>
#include <vector>
#include "../effects/debris_manager.hpp"
class EscenaLogo {
public:
@@ -21,7 +24,9 @@ private:
enum class EstatAnimacio {
PRE_ANIMATION, // Pantalla negra inicial
ANIMATION, // Animació de zoom de lletres
POST_ANIMATION // Logo complet visible
POST_ANIMATION, // Logo complet visible
EXPLOSION, // Explosió seqüencial de lletres
POST_EXPLOSION // Espera després de l'última explosió
};
SDLManager& sdl_;
@@ -29,6 +34,13 @@ private:
float
temps_estat_actual_; // Temps en l'estat actual (reset en cada transició)
// Gestor de fragments d'explosions
std::unique_ptr<Effects::DebrisManager> debris_manager_;
// Seguiment d'explosions seqüencials
size_t lletra_explosio_index_; // Índex de la següent lletra a explotar
float temps_des_ultima_explosio_; // Temps des de l'última explosió
// Estructura per a cada lletra del logo
struct LetraLogo {
std::shared_ptr<Graphics::Shape> forma;
@@ -40,26 +52,25 @@ private:
std::vector<LetraLogo> lletres_; // 9 lletres: J-A-I-L-G-A-M-E-S
// Constants d'animació
static constexpr float DURACIO_PRE =
1.5f; // Duració PRE_ANIMATION (pantalla negra)
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 =
4.0f; // Duració POST_ANIMATION (logo complet)
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 = 1.0f; // Temps entre explosions de lletres
static constexpr float VELOCITAT_EXPLOSIO = 80.0f; // Velocitat 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 d'animació 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 =
640.0f / 2.0f; // Punt inicial X del zoom (320)
static constexpr float ORIGEN_ZOOM_Y =
480.0f * 0.4f; // Punt inicial Y del zoom (240)
static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0)
static constexpr float ORIGEN_ZOOM_X = 640.0f / 2.0f; // Punt inicial X del zoom (320)
static constexpr float ORIGEN_ZOOM_Y = 480.0f * 0.4f; // Punt inicial Y del zoom (240)
// Mètodes privats
void inicialitzar_lletres();
void actualitzar(float delta_time);
void actualitzar_explosions(float delta_time);
void dibuixar();
void processar_events(const SDL_Event& event);

View File

@@ -1,12 +1,13 @@
#include "options.hpp"
#include "../core/defaults.hpp"
#include "../external/fkyaml_node.hpp"
#include "project.h"
#include <fstream>
#include <iostream>
#include <string>
#include "../core/defaults.hpp"
#include "../external/fkyaml_node.hpp"
#include "project.h"
namespace Options {
// Inicialitzar opcions amb valors per defecte de Defaults::

View File

@@ -1,4 +1,5 @@
#include <SDL2/SDL.h>
#include <string>
#include <vector>

View File

@@ -2,10 +2,11 @@
// © 1999 Visente i Sergi (versió Pascal)
// © 2025 Port a C++20 amb SDL3
#include "core/system/director.hpp"
#include <string>
#include <vector>
#include "core/system/director.hpp"
int main(int argc, char* argv[]) {
// Convertir arguments a std::vector<std::string>
std::vector<std::string> args(argv, argv + argc);