refactor(defaults): renombra VELOCITAT/CANVI_ANGLE/MAX_BALES a anglès
This commit is contained in:
@@ -17,10 +17,10 @@ namespace Defaults::Enemies {
|
|||||||
|
|
||||||
// Pentagon (esquivador - zigzag evasion)
|
// Pentagon (esquivador - zigzag evasion)
|
||||||
namespace Pentagon {
|
namespace Pentagon {
|
||||||
constexpr float VELOCITAT = 35.0F; // px/s (slightly slower)
|
constexpr float SPEED = 35.0F; // px/s (slightly slower)
|
||||||
constexpr float MASS = 5.0F; // Masa estándar
|
constexpr float MASS = 5.0F; // Masa estándar
|
||||||
constexpr float CANVI_ANGLE_PROB = 0.20F; // 20% per wall hit (frequent zigzag)
|
constexpr float ANGLE_CHANGE_PROB = 0.20F; // 20% per wall hit (frequent zigzag)
|
||||||
constexpr float CANVI_ANGLE_MAX = 1.0F; // Max random angle change (rad)
|
constexpr float ANGLE_CHANGE_MAX = 1.0F; // Max random angle change (rad)
|
||||||
constexpr float ZIGZAG_PROB_PER_SECOND = 0.8F; // Probabilidad de zigzag por segundo
|
constexpr float ZIGZAG_PROB_PER_SECOND = 0.8F; // Probabilidad de zigzag por segundo
|
||||||
constexpr float ROTATION_DELTA_MIN = 0.75F; // Min visual rotation (rad/s) [+50%]
|
constexpr float ROTATION_DELTA_MIN = 0.75F; // Min visual rotation (rad/s) [+50%]
|
||||||
constexpr float ROTATION_DELTA_MAX = 3.75F; // Max visual rotation (rad/s) [+50%]
|
constexpr float ROTATION_DELTA_MAX = 3.75F; // Max visual rotation (rad/s) [+50%]
|
||||||
@@ -29,7 +29,7 @@ namespace Defaults::Enemies {
|
|||||||
|
|
||||||
// Square (perseguidor - tracks player)
|
// Square (perseguidor - tracks player)
|
||||||
namespace Square {
|
namespace Square {
|
||||||
constexpr float VELOCITAT = 40.0F; // px/s (medium speed)
|
constexpr float SPEED = 40.0F; // px/s (medium speed)
|
||||||
constexpr float MASS = 8.0F; // Más pesado, "tanque"
|
constexpr float MASS = 8.0F; // Más pesado, "tanque"
|
||||||
constexpr float TRACKING_STRENGTH = 0.5F; // Interpolation toward player (0.0-1.0)
|
constexpr float TRACKING_STRENGTH = 0.5F; // Interpolation toward player (0.0-1.0)
|
||||||
constexpr float TRACKING_INTERVAL = 1.0F; // Seconds between angle updates
|
constexpr float TRACKING_INTERVAL = 1.0F; // Seconds between angle updates
|
||||||
@@ -40,10 +40,10 @@ namespace Defaults::Enemies {
|
|||||||
|
|
||||||
// Molinillo (agressiu - fast straight lines, proximity spin-up)
|
// Molinillo (agressiu - fast straight lines, proximity spin-up)
|
||||||
namespace Pinwheel {
|
namespace Pinwheel {
|
||||||
constexpr float VELOCITAT = 50.0F; // px/s (fastest)
|
constexpr float SPEED = 50.0F; // px/s (fastest)
|
||||||
constexpr float MASS = 4.0F; // Más liviano, ágil
|
constexpr float MASS = 4.0F; // Más liviano, ágil
|
||||||
constexpr float CANVI_ANGLE_PROB = 0.05F; // 5% per wall hit (rare direction change)
|
constexpr float ANGLE_CHANGE_PROB = 0.05F; // 5% per wall hit (rare direction change)
|
||||||
constexpr float CANVI_ANGLE_MAX = 0.3F; // Small angle adjustments
|
constexpr float ANGLE_CHANGE_MAX = 0.3F; // Small angle adjustments
|
||||||
constexpr float ROTATION_DELTA_MIN = 3.0F; // Base rotation (rad/s) [+50%]
|
constexpr float ROTATION_DELTA_MIN = 3.0F; // Base rotation (rad/s) [+50%]
|
||||||
constexpr float ROTATION_DELTA_MAX = 6.0F; // [+50%]
|
constexpr float ROTATION_DELTA_MAX = 6.0F; // [+50%]
|
||||||
constexpr float ROTATION_DELTA_PROXIMITY_MULTIPLIER = 3.0F; // Spin-up multiplier when near ship
|
constexpr float ROTATION_DELTA_PROXIMITY_MULTIPLIER = 3.0F; // Spin-up multiplier when near ship
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
namespace Defaults::Entities {
|
namespace Defaults::Entities {
|
||||||
|
|
||||||
constexpr int MAX_ORNIS = 15;
|
constexpr int MAX_ORNIS = 15;
|
||||||
constexpr int MAX_BALES = 50;
|
constexpr int MAX_BULLETS = 50;
|
||||||
|
|
||||||
constexpr float SHIP_RADIUS = 12.0F;
|
constexpr float SHIP_RADIUS = 12.0F;
|
||||||
constexpr float ENEMY_RADIUS = 20.0F;
|
constexpr float ENEMY_RADIUS = 20.0F;
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ namespace Defaults::Physics {
|
|||||||
|
|
||||||
// Explosions (debris physics)
|
// Explosions (debris physics)
|
||||||
namespace Debris {
|
namespace Debris {
|
||||||
constexpr float VELOCITAT_BASE = 80.0F; // Velocidad inicial (px/s)
|
constexpr float SPEED_BASE = 80.0F; // Velocidad inicial (px/s)
|
||||||
constexpr float VARIACIO_VELOCITAT = 40.0F; // ±variació aleatòria (px/s)
|
constexpr float VARIACIO_SPEED = 40.0F; // ±variació aleatòria (px/s)
|
||||||
constexpr float ACCELERACIO = -60.0F; // Fricció/desacceleració (px/s²)
|
constexpr float ACCELERACIO = -60.0F; // Fricció/desacceleració (px/s²)
|
||||||
constexpr float ROTATION_MIN = 0.1F; // Rotación mínima (rad/s ~5.7°/s)
|
constexpr float ROTATION_MIN = 0.1F; // Rotación mínima (rad/s ~5.7°/s)
|
||||||
constexpr float ROTATION_MAX = 0.3F; // Rotación màxima (rad/s ~17.2°/s)
|
constexpr float ROTATION_MAX = 0.3F; // Rotación màxima (rad/s ~17.2°/s)
|
||||||
constexpr float TEMPS_VIDA = 2.0F; // Vida mínima garantida (s) — després pot morir per velocitat baixa
|
constexpr float TEMPS_VIDA = 2.0F; // Vida mínima garantida (s) — després pot morir per velocitat baixa
|
||||||
constexpr float TEMPS_VIDA_NAU = 3.0F; // Ship debris min lifetime (matches DEATH_DURATION)
|
constexpr float TEMPS_VIDA_NAU = 3.0F; // Ship debris min lifetime (matches DEATH_DURATION)
|
||||||
constexpr float SHRINK_RATE = 1.0F; // Reducció de mida (1.0 = encoge a 0 al final del min_lifetime)
|
constexpr float SHRINK_RATE = 1.0F; // Reducció de mida (1.0 = encoge a 0 al final del min_lifetime)
|
||||||
|
|
||||||
// Política de mort: passat el min_lifetime, el fragment mor quan la
|
// Política de mort: passat el min_lifetime, el fragment mor quan la
|
||||||
// seva velocity cau per sota d'aquest llindar. Així els fragments
|
// seva velocity cau per sota d'aquest llindar. Així els fragments
|
||||||
@@ -68,7 +68,7 @@ namespace Defaults::Physics {
|
|||||||
// Angular velocity sin for trajectory inheritance
|
// Angular velocity sin for trajectory inheritance
|
||||||
// Excess above this threshold is converted to tangential linear velocity
|
// Excess above this threshold is converted to tangential linear velocity
|
||||||
// Prevents "vortex trap" problem with high-rotation enemies
|
// Prevents "vortex trap" problem with high-rotation enemies
|
||||||
constexpr float VELOCITAT_ROT_MAX = 1.5F; // rad/s (~86°/s)
|
constexpr float SPEED_ROT_MAX = 1.5F; // rad/s (~86°/s)
|
||||||
} // namespace Debris
|
} // namespace Debris
|
||||||
|
|
||||||
} // namespace Defaults::Physics
|
} // namespace Defaults::Physics
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace Constants {
|
namespace Constants {
|
||||||
// Límits de objectes
|
// Límits de objectes
|
||||||
constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
|
constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
|
||||||
constexpr int MAX_BALES = Defaults::Entities::MAX_BALES;
|
constexpr int MAX_BULLETS = Defaults::Entities::MAX_BULLETS;
|
||||||
|
|
||||||
// Matemàtiques
|
// Matemàtiques
|
||||||
constexpr float PI = Defaults::Math::PI;
|
constexpr float PI = Defaults::Math::PI;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ namespace Effects {
|
|||||||
float speed =
|
float speed =
|
||||||
velocitat_base +
|
velocitat_base +
|
||||||
(((std::rand() / static_cast<float>(RAND_MAX)) * 2.0F - 1.0F) *
|
(((std::rand() / static_cast<float>(RAND_MAX)) * 2.0F - 1.0F) *
|
||||||
Defaults::Physics::Debris::VARIACIO_VELOCITAT);
|
Defaults::Physics::Debris::VARIACIO_SPEED);
|
||||||
debris->velocity.x = (direccio.x * speed) + velocitat_objecte.x;
|
debris->velocity.x = (direccio.x * speed) + velocitat_objecte.x;
|
||||||
debris->velocity.y = (direccio.y * speed) + velocitat_objecte.y;
|
debris->velocity.y = (direccio.y * speed) + velocitat_objecte.y;
|
||||||
debris->acceleration = friction;
|
debris->acceleration = friction;
|
||||||
@@ -179,7 +179,7 @@ namespace Effects {
|
|||||||
velocitat_ang_heretada *= (1.0F + variacio);
|
velocitat_ang_heretada *= (1.0F + variacio);
|
||||||
|
|
||||||
// FASE 2: Cap a la velocity màxima; l'excés es converteix en tangencial
|
// FASE 2: Cap a la velocity màxima; l'excés es converteix en tangencial
|
||||||
constexpr float CAP = Defaults::Physics::Debris::VELOCITAT_ROT_MAX;
|
constexpr float CAP = Defaults::Physics::Debris::SPEED_ROT_MAX;
|
||||||
float abs_ang = std::abs(velocitat_ang_heretada);
|
float abs_ang = std::abs(velocitat_ang_heretada);
|
||||||
float sign_ang = (velocitat_ang_heretada >= 0.0F) ? 1.0F : -1.0F;
|
float sign_ang = (velocitat_ang_heretada >= 0.0F) ? 1.0F : -1.0F;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
|||||||
switch (type_) {
|
switch (type_) {
|
||||||
case EnemyType::PENTAGON:
|
case EnemyType::PENTAGON:
|
||||||
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
||||||
base_speed = Defaults::Enemies::Pentagon::VELOCITAT;
|
base_speed = Defaults::Enemies::Pentagon::SPEED;
|
||||||
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
||||||
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
||||||
type_mass = Defaults::Enemies::Pentagon::MASS;
|
type_mass = Defaults::Enemies::Pentagon::MASS;
|
||||||
@@ -73,7 +73,7 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
|||||||
|
|
||||||
case EnemyType::SQUARE:
|
case EnemyType::SQUARE:
|
||||||
shape_file = Defaults::Enemies::Square::SHAPE_FILE;
|
shape_file = Defaults::Enemies::Square::SHAPE_FILE;
|
||||||
base_speed = Defaults::Enemies::Square::VELOCITAT;
|
base_speed = Defaults::Enemies::Square::SPEED;
|
||||||
rotation_delta_min = Defaults::Enemies::Square::ROTATION_DELTA_MIN;
|
rotation_delta_min = Defaults::Enemies::Square::ROTATION_DELTA_MIN;
|
||||||
rotation_delta_max = Defaults::Enemies::Square::ROTATION_DELTA_MAX;
|
rotation_delta_max = Defaults::Enemies::Square::ROTATION_DELTA_MAX;
|
||||||
type_mass = Defaults::Enemies::Square::MASS;
|
type_mass = Defaults::Enemies::Square::MASS;
|
||||||
@@ -82,7 +82,7 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
|||||||
|
|
||||||
case EnemyType::PINWHEEL:
|
case EnemyType::PINWHEEL:
|
||||||
shape_file = Defaults::Enemies::Pinwheel::SHAPE_FILE;
|
shape_file = Defaults::Enemies::Pinwheel::SHAPE_FILE;
|
||||||
base_speed = Defaults::Enemies::Pinwheel::VELOCITAT;
|
base_speed = Defaults::Enemies::Pinwheel::SPEED;
|
||||||
rotation_delta_min = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MIN;
|
rotation_delta_min = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MIN;
|
||||||
rotation_delta_max = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MAX;
|
rotation_delta_max = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MAX;
|
||||||
type_mass = Defaults::Enemies::Pinwheel::MASS;
|
type_mass = Defaults::Enemies::Pinwheel::MASS;
|
||||||
@@ -92,7 +92,7 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
|||||||
std::cerr << "[Enemy] Error: tipo desconocido ("
|
std::cerr << "[Enemy] Error: tipo desconocido ("
|
||||||
<< static_cast<int>(type_) << "), usando PENTAGON\n";
|
<< static_cast<int>(type_) << "), usando PENTAGON\n";
|
||||||
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
||||||
base_speed = Defaults::Enemies::Pentagon::VELOCITAT;
|
base_speed = Defaults::Enemies::Pentagon::SPEED;
|
||||||
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
||||||
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
||||||
break;
|
break;
|
||||||
@@ -312,7 +312,7 @@ void Enemy::behaviorPentagon(float delta_time) {
|
|||||||
if (RAND_VAL < Defaults::Enemies::Pentagon::ZIGZAG_PROB_PER_SECOND * delta_time) {
|
if (RAND_VAL < Defaults::Enemies::Pentagon::ZIGZAG_PROB_PER_SECOND * delta_time) {
|
||||||
const float CURRENT_ANGLE = velocityToAngle(body_.velocity);
|
const float CURRENT_ANGLE = velocityToAngle(body_.velocity);
|
||||||
const float DELTA = (static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) *
|
const float DELTA = (static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) *
|
||||||
Defaults::Enemies::Pentagon::CANVI_ANGLE_MAX;
|
Defaults::Enemies::Pentagon::ANGLE_CHANGE_MAX;
|
||||||
const float NEW_ANGLE = CURRENT_ANGLE + ((std::rand() % 2 == 0) ? DELTA : -DELTA);
|
const float NEW_ANGLE = CURRENT_ANGLE + ((std::rand() % 2 == 0) ? DELTA : -DELTA);
|
||||||
const float SPEED = body_.velocity.length();
|
const float SPEED = body_.velocity.length();
|
||||||
setVelocityFromAngle(NEW_ANGLE, SPEED);
|
setVelocityFromAngle(NEW_ANGLE, SPEED);
|
||||||
@@ -454,13 +454,13 @@ auto Enemy::computeCurrentScale() const -> float {
|
|||||||
auto Enemy::getBaseVelocity() const -> float {
|
auto Enemy::getBaseVelocity() const -> float {
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case EnemyType::PENTAGON:
|
case EnemyType::PENTAGON:
|
||||||
return Defaults::Enemies::Pentagon::VELOCITAT;
|
return Defaults::Enemies::Pentagon::SPEED;
|
||||||
case EnemyType::SQUARE:
|
case EnemyType::SQUARE:
|
||||||
return Defaults::Enemies::Square::VELOCITAT;
|
return Defaults::Enemies::Square::SPEED;
|
||||||
case EnemyType::PINWHEEL:
|
case EnemyType::PINWHEEL:
|
||||||
return Defaults::Enemies::Pinwheel::VELOCITAT;
|
return Defaults::Enemies::Pinwheel::SPEED;
|
||||||
default:
|
default:
|
||||||
return Defaults::Enemies::Pentagon::VELOCITAT;
|
return Defaults::Enemies::Pentagon::SPEED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -743,7 +743,7 @@ void GameScene::tocado(uint8_t player_id) {
|
|||||||
SHIP_POS,
|
SHIP_POS,
|
||||||
SHIP_ANGLE,
|
SHIP_ANGLE,
|
||||||
1.0F,
|
1.0F,
|
||||||
Defaults::Physics::Debris::VELOCITAT_BASE,
|
Defaults::Physics::Debris::SPEED_BASE,
|
||||||
SHIP_BRIGHT,
|
SHIP_BRIGHT,
|
||||||
INHERITED_VEL,
|
INHERITED_VEL,
|
||||||
0.0F, // sense herència angular
|
0.0F, // sense herència angular
|
||||||
@@ -930,8 +930,8 @@ void GameScene::fireBullet(uint8_t player_id) {
|
|||||||
Vec2 fire_position = {.x = tip_x, .y = tip_y};
|
Vec2 fire_position = {.x = tip_x, .y = tip_y};
|
||||||
|
|
||||||
// Buscar primera bullet inactiva en el pool del player.
|
// Buscar primera bullet inactiva en el pool del player.
|
||||||
// El pool global té MAX_BALES slots per jugador (P1=[0..MAX-1], P2=[MAX..2*MAX-1]).
|
// El pool global té MAX_BULLETS slots per jugador (P1=[0..MAX-1], P2=[MAX..2*MAX-1]).
|
||||||
constexpr int SLOTS_PER_PLAYER = Defaults::Entities::MAX_BALES;
|
constexpr int SLOTS_PER_PLAYER = Defaults::Entities::MAX_BULLETS;
|
||||||
const int START_IDX = player_id * SLOTS_PER_PLAYER;
|
const int START_IDX = player_id * SLOTS_PER_PLAYER;
|
||||||
for (int i = START_IDX; i < START_IDX + SLOTS_PER_PLAYER; i++) {
|
for (int i = START_IDX; i < START_IDX + SLOTS_PER_PLAYER; i++) {
|
||||||
if (!bullets_[i].isActive()) {
|
if (!bullets_[i].isActive()) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class GameScene final : public Scene {
|
|||||||
std::array<Enemy, Constants::MAX_ORNIS> enemies_;
|
std::array<Enemy, Constants::MAX_ORNIS> enemies_;
|
||||||
// 6 balas: P1=[0,1,2], P2=[3,4,5]. El cast a size_t evita la
|
// 6 balas: P1=[0,1,2], P2=[3,4,5]. El cast a size_t evita la
|
||||||
// widening conversion implícita que detecta clang-tidy.
|
// widening conversion implícita que detecta clang-tidy.
|
||||||
std::array<Bullet, static_cast<std::size_t>(Constants::MAX_BALES) * 2> bullets_;
|
std::array<Bullet, static_cast<std::size_t>(Constants::MAX_BULLETS) * 2> bullets_;
|
||||||
std::array<float, 2> hit_timer_per_player_; // Death timers per player (seconds)
|
std::array<float, 2> hit_timer_per_player_; // Death timers per player (seconds)
|
||||||
|
|
||||||
// Lives and game over system
|
// Lives and game over system
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ static auto computeLetterProgress(size_t letra_index, size_t num_letras, float g
|
|||||||
LogoScene::LogoScene(SDLManager& sdl, SceneContext& context)
|
LogoScene::LogoScene(SDLManager& sdl, SceneContext& context)
|
||||||
: sdl_(sdl),
|
: sdl_(sdl),
|
||||||
context_(context),
|
context_(context),
|
||||||
|
|
||||||
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.getRenderer()))
|
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.getRenderer())) {
|
||||||
{
|
|
||||||
std::cout << "SceneType Logo: Inicialitzant...\n";
|
std::cout << "SceneType Logo: Inicialitzant...\n";
|
||||||
|
|
||||||
// Consumir opciones (LOGO no processa opciones actualment)
|
// Consumir opciones (LOGO no processa opciones actualment)
|
||||||
@@ -196,10 +195,10 @@ void LogoScene::updateExplosions(float delta_time) {
|
|||||||
|
|
||||||
debris_manager_->explode(
|
debris_manager_->explode(
|
||||||
lletra.shape, // Forma a explode
|
lletra.shape, // Forma a explode
|
||||||
lletra.position, // Posición
|
lletra.position, // Posición
|
||||||
0.0F, // Angle (sin rotación)
|
0.0F, // Angle (sin rotación)
|
||||||
ESCALA_FINAL, // Escala (lletres a scale final)
|
ESCALA_FINAL, // Escala (lletres a scale final)
|
||||||
VELOCITAT_EXPLOSIO, // Velocidad base
|
SPEED_EXPLOSIO, // Velocidad base
|
||||||
1.0F, // Brightness màxim (per defecte)
|
1.0F, // Brightness màxim (per defecte)
|
||||||
{.x = 0.0F, .y = 0.0F} // Sin velocity (per defecte)
|
{.x = 0.0F, .y = 0.0F} // Sin velocity (per defecte)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,76 +20,76 @@
|
|||||||
#include "game/effects/debris_manager.hpp"
|
#include "game/effects/debris_manager.hpp"
|
||||||
|
|
||||||
class LogoScene final : public Scene {
|
class LogoScene final : public Scene {
|
||||||
public:
|
public:
|
||||||
explicit LogoScene(SDLManager& sdl, SceneManager::SceneContext& context);
|
explicit LogoScene(SDLManager& sdl, SceneManager::SceneContext& context);
|
||||||
~LogoScene() override; // Destructor per aturar sons
|
~LogoScene() override; // Destructor per aturar sons
|
||||||
|
|
||||||
// Scene interface
|
// Scene interface
|
||||||
void handleEvent(const SDL_Event& event) override;
|
void handleEvent(const SDL_Event& event) override;
|
||||||
void update(float delta_time) override;
|
void update(float delta_time) override;
|
||||||
void draw() override;
|
void draw() override;
|
||||||
[[nodiscard]] auto isFinished() const -> bool override;
|
[[nodiscard]] auto isFinished() const -> bool override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Màquina de estats per l'animación
|
// Màquina de estats per l'animación
|
||||||
enum class AnimationState : std::uint8_t {
|
enum class AnimationState : std::uint8_t {
|
||||||
PRE_ANIMATION, // Pantalla negra inicial
|
PRE_ANIMATION, // Pantalla negra inicial
|
||||||
ANIMATION, // Animación de zoom de lletres
|
ANIMATION, // Animación de zoom de lletres
|
||||||
POST_ANIMATION, // Logo complet visible
|
POST_ANIMATION, // Logo complet visible
|
||||||
EXPLOSION, // Explosión seqüencial de lletres
|
EXPLOSION, // Explosión seqüencial de lletres
|
||||||
POST_EXPLOSION // Espera después de l'última explosión
|
POST_EXPLOSION // Espera después de l'última explosión
|
||||||
};
|
};
|
||||||
|
|
||||||
SDLManager& sdl_;
|
SDLManager& sdl_;
|
||||||
SceneManager::SceneContext& context_;
|
SceneManager::SceneContext& context_;
|
||||||
AnimationState estat_actual_{AnimationState::PRE_ANIMATION}; // Estat actual de la màquina
|
AnimationState estat_actual_{AnimationState::PRE_ANIMATION}; // Estat actual de la màquina
|
||||||
float
|
float
|
||||||
temps_estat_actual_{0.0F}; // Temps en l'state actual (reset en cada transición)
|
temps_estat_actual_{0.0F}; // Temps en l'state actual (reset en cada transición)
|
||||||
|
|
||||||
// Gestor de fragments de explosions
|
// Gestor de fragments de explosions
|
||||||
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
||||||
|
|
||||||
// Seguiment de explosions seqüencials
|
// Seguiment de explosions seqüencials
|
||||||
size_t lletra_explosio_index_{0}; // Índex de la següent lletra a explode
|
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
|
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
|
std::vector<size_t> ordre_explosio_; // Ordre aleatori de índexs de lletres
|
||||||
|
|
||||||
// Estructura para cada lletra del logo
|
// Estructura para cada lletra del logo
|
||||||
struct LetraLogo {
|
struct LetraLogo {
|
||||||
std::shared_ptr<Graphics::Shape> shape;
|
std::shared_ptr<Graphics::Shape> shape;
|
||||||
Vec2 position; // Posición final en pantalla
|
Vec2 position; // Posición final en pantalla
|
||||||
float ancho; // Ancho del bounding box
|
float ancho; // Ancho del bounding box
|
||||||
float offset_centre; // Distancia de min_x a shape_centre.x
|
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
|
std::vector<LetraLogo> lletres_; // 9 lletres: J-A-I-L-G-A-M-E-S
|
||||||
|
|
||||||
// Seguiment de sons de lletres (evitar reproduccions repetides)
|
// Seguiment de sons de lletres (evitar reproduccions repetides)
|
||||||
std::array<bool, 9> so_reproduit_; // Track si cada lletra ya ha reproduit el so
|
std::array<bool, 9> so_reproduit_; // Track si cada lletra ya ha reproduit el so
|
||||||
|
|
||||||
// Constants de animación
|
// Constants de animación
|
||||||
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_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_ANIMATION = 3.0F; // Duració POST_ANIMATION (logo complet)
|
||||||
static constexpr float DURACIO_POST_EXPLOSION = 3.0F; // Duració POST_EXPLOSION (espera final)
|
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 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 SPEED_EXPLOSIO = 240.0F; // Velocidad base fragments (px/s)
|
||||||
static constexpr float ESCALA_INICIAL = 0.1F; // Escala inicial (10%)
|
static constexpr float ESCALA_INICIAL = 0.1F; // Escala inicial (10%)
|
||||||
static constexpr float ESCALA_FINAL = 0.8F; // Escala final (80%)
|
static constexpr float ESCALA_FINAL = 0.8F; // Escala final (80%)
|
||||||
static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espaiat entre lletres
|
static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espaiat entre lletres
|
||||||
|
|
||||||
// Constants de animación seqüencial
|
// 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 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_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
|
static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4F; // Vec2 inicial Y del zoom
|
||||||
|
|
||||||
// Métodos privats
|
// Métodos privats
|
||||||
void initLetters();
|
void initLetters();
|
||||||
void updateExplosions(float delta_time);
|
void updateExplosions(float delta_time);
|
||||||
// Estático: solo consulta Input (singleton), no estado de la escena.
|
// Estático: solo consulta Input (singleton), no estado de la escena.
|
||||||
static auto checkSkipButtonPressed() -> bool;
|
static auto checkSkipButtonPressed() -> bool;
|
||||||
|
|
||||||
// Métodos de gestió de estats
|
// Métodos de gestió de estats
|
||||||
void changeState(AnimationState nou_estat);
|
void changeState(AnimationState nou_estat);
|
||||||
[[nodiscard]] auto allLettersComplete() const -> bool;
|
[[nodiscard]] auto allLettersComplete() const -> bool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ namespace Systems::Collision {
|
|||||||
|
|
||||||
enemy.destroy();
|
enemy.destroy();
|
||||||
|
|
||||||
constexpr float VELOCITAT_EXPLOSIO = 80.0F; // px/s (explosión suave)
|
constexpr float SPEED_EXPLOSIO = 80.0F; // px/s (explosión suave)
|
||||||
const Vec2 INHERITED_VEL = ENEMY_VEL * Defaults::Physics::Debris::ENEMY_VELOCITY_INHERITANCE;
|
const Vec2 INHERITED_VEL = ENEMY_VEL * Defaults::Physics::Debris::ENEMY_VELOCITY_INHERITANCE;
|
||||||
ctx.debris_manager.explode(
|
ctx.debris_manager.explode(
|
||||||
SHAPE,
|
SHAPE,
|
||||||
ENEMY_POS,
|
ENEMY_POS,
|
||||||
0.0F, // angle (rotación interna del enemy)
|
0.0F, // angle (rotación interna del enemy)
|
||||||
1.0F, // escala
|
1.0F, // escala
|
||||||
VELOCITAT_EXPLOSIO,
|
SPEED_EXPLOSIO,
|
||||||
BRIGHTNESS,
|
BRIGHTNESS,
|
||||||
INHERITED_VEL,
|
INHERITED_VEL,
|
||||||
0.0F, // sense herència angular: evita que els 5 trossos curvin en bloc
|
0.0F, // sense herència angular: evita que els 5 trossos curvin en bloc
|
||||||
@@ -297,7 +297,7 @@ namespace Systems::Collision {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void desactivateOutOfBoundsBullets(
|
void desactivateOutOfBoundsBullets(
|
||||||
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BALES) * 2>& bullets,
|
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BULLETS) * 2>& bullets,
|
||||||
Effects::DebrisManager& debris_manager) {
|
Effects::DebrisManager& debris_manager) {
|
||||||
float min_x;
|
float min_x;
|
||||||
float max_x;
|
float max_x;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Systems::Collision {
|
|||||||
struct Context {
|
struct Context {
|
||||||
std::array<Ship, 2>& ships;
|
std::array<Ship, 2>& ships;
|
||||||
std::array<Enemy, Defaults::Entities::MAX_ORNIS>& enemies;
|
std::array<Enemy, Defaults::Entities::MAX_ORNIS>& enemies;
|
||||||
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BALES) * 2>& bullets;
|
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BULLETS) * 2>& bullets;
|
||||||
std::array<float, 2>& hit_timer_per_player;
|
std::array<float, 2>& hit_timer_per_player;
|
||||||
std::array<int, 2>& score_per_player;
|
std::array<int, 2>& score_per_player;
|
||||||
std::array<int, 2>& lives_per_player;
|
std::array<int, 2>& lives_per_player;
|
||||||
@@ -74,7 +74,7 @@ namespace Systems::Collision {
|
|||||||
// (8 fragments de l'octàgon) i el so HIT. Cal cridar-la després de detectAll()
|
// (8 fragments de l'octàgon) i el so HIT. Cal cridar-la després de detectAll()
|
||||||
// perquè una bala que el mateix frame xoca i alhora surt es comptabilitzi com a impacte.
|
// perquè una bala que el mateix frame xoca i alhora surt es comptabilitzi com a impacte.
|
||||||
void desactivateOutOfBoundsBullets(
|
void desactivateOutOfBoundsBullets(
|
||||||
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BALES) * 2>& bullets,
|
std::array<Bullet, static_cast<std::size_t>(Defaults::Entities::MAX_BULLETS) * 2>& bullets,
|
||||||
Effects::DebrisManager& debris_manager);
|
Effects::DebrisManager& debris_manager);
|
||||||
|
|
||||||
} // namespace Systems::Collision
|
} // namespace Systems::Collision
|
||||||
|
|||||||
Reference in New Issue
Block a user