layout de TITOL
This commit is contained in:
@@ -5,7 +5,9 @@ project(orni VERSION 0.6.0)
|
|||||||
|
|
||||||
# Info del proyecto
|
# Info del proyecto
|
||||||
set(PROJECT_LONG_NAME "Orni Attack")
|
set(PROJECT_LONG_NAME "Orni Attack")
|
||||||
set(PROJECT_COPYRIGHT "© 1999 Visente i Sergi, 2025 Port")
|
set(PROJECT_COPYRIGHT_ORIGINAL "© 1999 Visente i Sergi")
|
||||||
|
set(PROJECT_COPYRIGHT_PORT "© 2025 JailDesigner")
|
||||||
|
set(PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT_ORIGINAL}, ${PROJECT_COPYRIGHT_PORT}")
|
||||||
|
|
||||||
# Establecer estándar de C++
|
# Establecer estándar de C++
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include "core/audio/audio_cache.hpp"
|
#include "core/audio/audio_cache.hpp"
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "core/resources/resource_helper.hpp"
|
||||||
|
|
||||||
// Inicialització de variables estàtiques
|
// Inicialització de variables estàtiques
|
||||||
std::unordered_map<std::string, JA_Sound_t*> AudioCache::sounds_;
|
std::unordered_map<std::string, JA_Sound_t*> AudioCache::sounds_;
|
||||||
std::unordered_map<std::string, JA_Music_t*> AudioCache::musics_;
|
std::unordered_map<std::string, JA_Music_t*> AudioCache::musics_;
|
||||||
|
|||||||
@@ -361,44 +361,85 @@ constexpr int MOLINILLO_SCORE = 200; // Molinillo (agressiu, 50 px/s)
|
|||||||
// Title scene ship animations (naus 3D flotants a l'escena de títol)
|
// Title scene ship animations (naus 3D flotants a l'escena de títol)
|
||||||
namespace Title {
|
namespace Title {
|
||||||
namespace Ships {
|
namespace Ships {
|
||||||
// Posicions clock (coordenades polars des del centre 320, 240)
|
// ============================================================
|
||||||
// En coordenades de pantalla: 0° = dreta, 90° = baix, 180° = esquerra, 270° = dalt
|
// PARÀMETRES BASE (ajustar aquí per experimentar)
|
||||||
constexpr float CLOCK_8_ANGLE = 150.0f * Math::PI / 180.0f; // 8 o'clock = bottom-left
|
// ============================================================
|
||||||
constexpr float CLOCK_4_ANGLE = 30.0f * Math::PI / 180.0f; // 4 o'clock = bottom-right
|
|
||||||
|
// 1. Escala global de les naus
|
||||||
|
constexpr float SHIP_BASE_SCALE = 2.5f; // Multiplicador (1.0 = mida original del .shp)
|
||||||
|
|
||||||
|
// 2. Altura vertical (cercanía al centro)
|
||||||
|
// Ratio Y desde el centro de la pantalla (0.0 = centro, 1.0 = bottom de pantalla)
|
||||||
|
constexpr float TARGET_Y_RATIO = 0.15625f;
|
||||||
|
|
||||||
|
// 3. Radio orbital (distancia radial desde centro en coordenadas polares)
|
||||||
constexpr float CLOCK_RADIUS = 150.0f; // Distància des del centre
|
constexpr float CLOCK_RADIUS = 150.0f; // Distància des del centre
|
||||||
|
|
||||||
// P1 (8 o'clock, bottom-left)
|
// 4. Ángulos de posición (clock positions en coordenadas polares)
|
||||||
// 150° → cos(150°)=-0.866, sin(150°)=0.5 → X = 320 - 130 = 190, Y = 240 + 75 = 315
|
// En coordenades de pantalla: 0° = dreta, 90° = baix, 180° = esquerra, 270° = dalt
|
||||||
constexpr float P1_TARGET_X = 190.0f;
|
constexpr float CLOCK_8_ANGLE = 150.0f * Math::PI / 180.0f; // 8 o'clock (bottom-left)
|
||||||
constexpr float P1_TARGET_Y = 315.0f;
|
constexpr float CLOCK_4_ANGLE = 30.0f * Math::PI / 180.0f; // 4 o'clock (bottom-right)
|
||||||
|
|
||||||
// P2 (4 o'clock, bottom-right)
|
// 5. Radio máximo de la forma de la nave (para calcular offset automáticamente)
|
||||||
// 30° → cos(30°)=0.866, sin(30°)=0.5 → X = 320 + 130 = 450, Y = 240 + 75 = 315
|
constexpr float SHIP_MAX_RADIUS = 30.0f; // Radi del cercle circumscrit a ship_p1.shp
|
||||||
constexpr float P2_TARGET_X = 450.0f;
|
|
||||||
constexpr float P2_TARGET_Y = 315.0f;
|
|
||||||
|
|
||||||
// Escala base de les naus (ajusta aquí per fer-les més grans o petites)
|
// 6. Margen de seguridad para offset de entrada
|
||||||
constexpr float SHIP_BASE_SCALE = 2.5f; // Multiplicador global (1.0 = mida original)
|
constexpr float ENTRY_OFFSET_MARGIN = 227.5f; // Para offset total de ~340px (ajustado)
|
||||||
|
|
||||||
// Escales d'animació (perspectiva ja incorporada a les formes .shp)
|
// ============================================================
|
||||||
constexpr float ENTRY_SCALE_START = 1.5f * SHIP_BASE_SCALE; // Més gran per veure millor
|
// VALORS DERIVATS (calculats automàticament - NO modificar)
|
||||||
constexpr float FLOATING_SCALE = 1.0f * SHIP_BASE_SCALE; // Mida normal (més grans)
|
// ============================================================
|
||||||
|
|
||||||
// Animacions
|
// Centre de la pantalla (punt de referència)
|
||||||
constexpr float ENTRY_DURATION = 2.0f; // Entrada
|
constexpr float CENTER_X = Game::WIDTH / 2.0f; // 320.0f
|
||||||
constexpr float ENTRY_OFFSET = 340.0f; // Offset fora de pantalla (considera radi màxim 30px * escala 3.75 + marge)
|
constexpr float CENTER_Y = Game::HEIGHT / 2.0f; // 240.0f
|
||||||
constexpr float EXIT_DURATION = 1.0f; // Sortida (configurable)
|
|
||||||
|
// Posicions target (calculades dinàmicament des dels paràmetres base)
|
||||||
|
// Nota: std::cos/sin no són constexpr en C++20, però funcionen en runtime
|
||||||
|
// Les funcions inline són optimitzades pel compilador (zero overhead)
|
||||||
|
inline float P1_TARGET_X() {
|
||||||
|
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE);
|
||||||
|
}
|
||||||
|
inline float P1_TARGET_Y() {
|
||||||
|
return CENTER_Y + (Game::HEIGHT / 2.0f) * TARGET_Y_RATIO;
|
||||||
|
}
|
||||||
|
inline float P2_TARGET_X() {
|
||||||
|
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE);
|
||||||
|
}
|
||||||
|
inline float P2_TARGET_Y() {
|
||||||
|
return CENTER_Y + (Game::HEIGHT / 2.0f) * TARGET_Y_RATIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escales d'animació (relatives a SHIP_BASE_SCALE)
|
||||||
|
constexpr float ENTRY_SCALE_START = 1.5f * SHIP_BASE_SCALE; // Entrada: 50% més gran
|
||||||
|
constexpr float FLOATING_SCALE = 1.0f * SHIP_BASE_SCALE; // Flotant: escala base
|
||||||
|
|
||||||
|
// Offset d'entrada (ajustat automàticament a l'escala)
|
||||||
|
// Fórmula: (radi màxim de la nau * escala d'entrada) + marge
|
||||||
|
constexpr float ENTRY_OFFSET = (SHIP_MAX_RADIUS * ENTRY_SCALE_START) + ENTRY_OFFSET_MARGIN;
|
||||||
|
|
||||||
|
// Punt de fuga (centre per a l'animació de sortida)
|
||||||
|
constexpr float VANISHING_POINT_X = CENTER_X; // 320.0f
|
||||||
|
constexpr float VANISHING_POINT_Y = CENTER_Y; // 240.0f
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// ANIMACIONS (durades, oscil·lacions, delays)
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
// Durades d'animació
|
||||||
|
constexpr float ENTRY_DURATION = 2.0f; // Entrada (segons)
|
||||||
|
constexpr float EXIT_DURATION = 1.0f; // Sortida (segons)
|
||||||
|
|
||||||
// Flotació (oscil·lació reduïda i diferenciada per nau)
|
// Flotació (oscil·lació reduïda i diferenciada per nau)
|
||||||
constexpr float FLOAT_AMPLITUDE_X = 4.0f; // Era 6.0f
|
constexpr float FLOAT_AMPLITUDE_X = 4.0f; // Amplitud X (píxels)
|
||||||
constexpr float FLOAT_AMPLITUDE_Y = 2.5f; // Era 4.0f
|
constexpr float FLOAT_AMPLITUDE_Y = 2.5f; // Amplitud Y (píxels)
|
||||||
|
|
||||||
// Freqüències base
|
// Freqüències base
|
||||||
constexpr float FLOAT_FREQUENCY_X_BASE = 0.5f;
|
constexpr float FLOAT_FREQUENCY_X_BASE = 0.5f; // Hz
|
||||||
constexpr float FLOAT_FREQUENCY_Y_BASE = 0.7f;
|
constexpr float FLOAT_FREQUENCY_Y_BASE = 0.7f; // Hz
|
||||||
constexpr float FLOAT_PHASE_OFFSET = 1.57f; // π/2 (90°)
|
constexpr float FLOAT_PHASE_OFFSET = 1.57f; // π/2 (90°)
|
||||||
|
|
||||||
// Delays d'entrada
|
// Delays d'entrada (per a entrada escalonada)
|
||||||
constexpr float P1_ENTRY_DELAY = 0.0f; // P1 entra immediatament
|
constexpr float P1_ENTRY_DELAY = 0.0f; // P1 entra immediatament
|
||||||
constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
|
constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
|
||||||
|
|
||||||
@@ -406,10 +447,26 @@ constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
|
|||||||
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88f; // 12% més lenta
|
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88f; // 12% més lenta
|
||||||
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12f; // 12% més ràpida
|
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12f; // 12% més ràpida
|
||||||
|
|
||||||
// Punt de fuga
|
|
||||||
constexpr float VANISHING_POINT_X = Game::WIDTH / 2.0f; // 320.0f
|
|
||||||
constexpr float VANISHING_POINT_Y = Game::HEIGHT / 2.0f; // 240.0f
|
|
||||||
} // namespace Ships
|
} // namespace Ships
|
||||||
|
|
||||||
|
namespace Layout {
|
||||||
|
// Posicions verticals (anclatges des del TOP de pantalla lògica, 0.0-1.0)
|
||||||
|
constexpr float LOGO_POS = 0.20f; // Logo "ORNI"
|
||||||
|
constexpr float PRESS_START_POS = 0.73f; // "PRESS START TO PLAY"
|
||||||
|
constexpr float COPYRIGHT1_POS = 0.87f; // Primera línia copyright
|
||||||
|
|
||||||
|
// Separacions relatives (proporció respecte Game::HEIGHT = 480px)
|
||||||
|
constexpr float LOGO_LINE_SPACING = 0.02f; // Entre "ORNI" i "ATTACK!" (10px)
|
||||||
|
constexpr float COPYRIGHT_LINE_SPACING = 0.0f; // Entre línies copyright (5px)
|
||||||
|
|
||||||
|
// Factors d'escala
|
||||||
|
constexpr float LOGO_SCALE = 0.6f; // Escala "ORNI ATTACK!"
|
||||||
|
constexpr float PRESS_START_SCALE = 1.0f; // Escala "PRESS START TO PLAY"
|
||||||
|
constexpr float COPYRIGHT_SCALE = 0.5f; // Escala copyright
|
||||||
|
|
||||||
|
// Espaiat entre caràcters (usat per VectorText)
|
||||||
|
constexpr float TEXT_SPACING = 2.0f;
|
||||||
|
} // namespace Layout
|
||||||
} // namespace Title
|
} // namespace Title
|
||||||
|
|
||||||
// Floating score numbers (números flotants de puntuació)
|
// Floating score numbers (números flotants de puntuació)
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include "core/graphics/shape_loader.hpp"
|
#include "core/graphics/shape_loader.hpp"
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "core/resources/resource_helper.hpp"
|
||||||
|
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
|
|
||||||
// Inicialització de variables estàtiques
|
// Inicialització de variables estàtiques
|
||||||
|
|||||||
@@ -38,5 +38,4 @@ extern const std::unordered_map<std::string, SDL_GamepadButton> STRING_TO_BUTTON
|
|||||||
static constexpr std::array<InputAction, 3> ARCADE_BUTTONS = {
|
static constexpr std::array<InputAction, 3> ARCADE_BUTTONS = {
|
||||||
InputAction::SHOOT,
|
InputAction::SHOOT,
|
||||||
InputAction::THRUST,
|
InputAction::THRUST,
|
||||||
InputAction::START
|
InputAction::START};
|
||||||
};
|
|
||||||
|
|||||||
@@ -18,8 +18,14 @@ struct Rotation3D {
|
|||||||
float yaw; // Rotació eix Y (guiñada esquerra/dreta)
|
float yaw; // Rotació eix Y (guiñada esquerra/dreta)
|
||||||
float roll; // Rotació eix Z (alabeo lateral)
|
float roll; // Rotació eix Z (alabeo lateral)
|
||||||
|
|
||||||
Rotation3D() : pitch(0.0f), yaw(0.0f), roll(0.0f) {}
|
Rotation3D()
|
||||||
Rotation3D(float p, float y, float r) : pitch(p), yaw(y), roll(r) {}
|
: pitch(0.0f),
|
||||||
|
yaw(0.0f),
|
||||||
|
roll(0.0f) {}
|
||||||
|
Rotation3D(float p, float y, float r)
|
||||||
|
: pitch(p),
|
||||||
|
yaw(y),
|
||||||
|
roll(r) {}
|
||||||
|
|
||||||
bool has_rotation() const {
|
bool has_rotation() const {
|
||||||
return pitch != 0.0f || yaw != 0.0f || roll != 0.0f;
|
return pitch != 0.0f || yaw != 0.0f || roll != 0.0f;
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include "resource_helper.hpp"
|
#include "resource_helper.hpp"
|
||||||
|
|
||||||
#include "resource_loader.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "resource_loader.hpp"
|
||||||
|
|
||||||
namespace Resource {
|
namespace Resource {
|
||||||
namespace Helper {
|
namespace Helper {
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resource_pack.hpp"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "resource_pack.hpp"
|
||||||
|
|
||||||
namespace Resource {
|
namespace Resource {
|
||||||
|
|
||||||
// Singleton per gestionar la càrrega de recursos
|
// Singleton per gestionar la càrrega de recursos
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "context_escenes.hpp"
|
||||||
#include "core/audio/audio.hpp"
|
#include "core/audio/audio.hpp"
|
||||||
#include "core/audio/audio_cache.hpp"
|
#include "core/audio/audio_cache.hpp"
|
||||||
#include "core/defaults.hpp"
|
#include "core/defaults.hpp"
|
||||||
@@ -20,7 +21,6 @@
|
|||||||
#include "game/escenes/escena_logo.hpp"
|
#include "game/escenes/escena_logo.hpp"
|
||||||
#include "game/escenes/escena_titol.hpp"
|
#include "game/escenes/escena_titol.hpp"
|
||||||
#include "game/options.hpp"
|
#include "game/options.hpp"
|
||||||
#include "context_escenes.hpp"
|
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@@ -240,7 +240,7 @@ auto Director::run() -> int {
|
|||||||
// Crear context d'escenes
|
// Crear context d'escenes
|
||||||
ContextEscenes context;
|
ContextEscenes context;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
context.canviar_escena(Escena::JOC);
|
context.canviar_escena(Escena::TITOL);
|
||||||
#else
|
#else
|
||||||
context.canviar_escena(Escena::LOGO);
|
context.canviar_escena(Escena::LOGO);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "context_escenes.hpp"
|
||||||
#include "core/input/input.hpp"
|
#include "core/input/input.hpp"
|
||||||
#include "core/input/mouse.hpp"
|
#include "core/input/mouse.hpp"
|
||||||
#include "core/rendering/sdl_manager.hpp"
|
#include "core/rendering/sdl_manager.hpp"
|
||||||
#include "context_escenes.hpp"
|
|
||||||
|
|
||||||
// Using declarations per simplificar el codi
|
// Using declarations per simplificar el codi
|
||||||
using GestorEscenes::ContextEscenes;
|
using GestorEscenes::ContextEscenes;
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
class SDLManager;
|
class SDLManager;
|
||||||
namespace GestorEscenes { class ContextEscenes; }
|
namespace GestorEscenes {
|
||||||
|
class ContextEscenes;
|
||||||
|
}
|
||||||
|
|
||||||
namespace GlobalEvents {
|
namespace GlobalEvents {
|
||||||
// Processa events globals (F1/F2/F3/ESC/QUIT)
|
// Processa events globals (F1/F2/F3/ESC/QUIT)
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
namespace Effects {
|
namespace Effects {
|
||||||
|
|
||||||
GestorPuntuacioFlotant::GestorPuntuacioFlotant(SDL_Renderer* renderer)
|
GestorPuntuacioFlotant::GestorPuntuacioFlotant(SDL_Renderer* renderer)
|
||||||
: renderer_(renderer), text_(renderer) {
|
: renderer_(renderer),
|
||||||
|
text_(renderer) {
|
||||||
// Inicialitzar tots els slots com inactius
|
// Inicialitzar tots els slots com inactius
|
||||||
for (auto& pf : pool_) {
|
for (auto& pf : pool_) {
|
||||||
pf.actiu = false;
|
pf.actiu = false;
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ class Enemic {
|
|||||||
Punt get_velocitat_vector() const {
|
Punt get_velocitat_vector() const {
|
||||||
return {
|
return {
|
||||||
velocitat_ * std::cos(angle_ - Constants::PI / 2.0f),
|
velocitat_ * std::cos(angle_ - Constants::PI / 2.0f),
|
||||||
velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)
|
velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ship position reference for tracking behavior
|
// Set ship position reference for tracking behavior
|
||||||
@@ -68,7 +67,10 @@ class Enemic {
|
|||||||
|
|
||||||
// [NEW] Setters for difficulty multipliers (stage system)
|
// [NEW] Setters for difficulty multipliers (stage system)
|
||||||
void set_velocity(float vel) { velocitat_ = vel; }
|
void set_velocity(float vel) { velocitat_ = vel; }
|
||||||
void set_rotation(float rot) { drotacio_ = rot; animacio_.drotacio_base = rot; }
|
void set_rotation(float rot) {
|
||||||
|
drotacio_ = rot;
|
||||||
|
animacio_.drotacio_base = rot;
|
||||||
|
}
|
||||||
void set_tracking_strength(float strength);
|
void set_tracking_strength(float strength);
|
||||||
|
|
||||||
// [NEW] Invulnerability queries
|
// [NEW] Invulnerability queries
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ class Nau {
|
|||||||
Punt get_velocitat_vector() const {
|
Punt get_velocitat_vector() const {
|
||||||
return {
|
return {
|
||||||
velocitat_ * std::cos(angle_ - Constants::PI / 2.0f),
|
velocitat_ * std::cos(angle_ - Constants::PI / 2.0f),
|
||||||
velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)
|
velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|||||||
@@ -323,22 +323,19 @@ void EscenaJoc::actualitzar(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcular global progress (0.0 al inicio → 1.0 al final)
|
// Calcular global progress (0.0 al inicio → 1.0 al final)
|
||||||
float global_progress = 1.0f - (stage_manager_->get_timer_transicio() /
|
float global_progress = 1.0f - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION);
|
||||||
Defaults::Game::INIT_HUD_DURATION);
|
|
||||||
global_progress = std::min(1.0f, global_progress);
|
global_progress = std::min(1.0f, global_progress);
|
||||||
|
|
||||||
// [NEW] Calcular progress independiente para cada nave
|
// [NEW] Calcular progress independiente para cada nave
|
||||||
float ship1_progress = calcular_progress_rango(
|
float ship1_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_END
|
Defaults::Game::INIT_HUD_SHIP1_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
float ship2_progress = calcular_progress_rango(
|
float ship2_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END
|
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
// [MODIFICAT] Animar AMBAS naus con sus progress respectivos
|
// [MODIFICAT] Animar AMBAS naus con sus progress respectivos
|
||||||
if (config_partida_.jugador1_actiu && ship1_progress < 1.0f) {
|
if (config_partida_.jugador1_actiu && ship1_progress < 1.0f) {
|
||||||
@@ -501,26 +498,22 @@ void EscenaJoc::dibuixar() {
|
|||||||
float rect_progress = calcular_progress_rango(
|
float rect_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_RECT_RATIO_INIT,
|
Defaults::Game::INIT_HUD_RECT_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_RECT_RATIO_END
|
Defaults::Game::INIT_HUD_RECT_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
float score_progress = calcular_progress_rango(
|
float score_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_SCORE_RATIO_INIT,
|
Defaults::Game::INIT_HUD_SCORE_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_SCORE_RATIO_END
|
Defaults::Game::INIT_HUD_SCORE_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
float ship1_progress = calcular_progress_rango(
|
float ship1_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_END
|
Defaults::Game::INIT_HUD_SHIP1_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
float ship2_progress = calcular_progress_rango(
|
float ship2_progress = calcular_progress_rango(
|
||||||
global_progress,
|
global_progress,
|
||||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
||||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END
|
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||||
);
|
|
||||||
|
|
||||||
// Dibuixar elements animats
|
// Dibuixar elements animats
|
||||||
if (rect_progress > 0.0f) {
|
if (rect_progress > 0.0f) {
|
||||||
@@ -1099,8 +1092,7 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
zona.x + zona.w * x_ratio,
|
zona.x + zona.w * x_ratio,
|
||||||
zona.y + zona.h * Defaults::Game::SPAWN_Y_RATIO
|
zona.y + zona.h * Defaults::Game::SPAWN_Y_RATIO};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EscenaJoc::disparar_bala(uint8_t player_id) {
|
void EscenaJoc::disparar_bala(uint8_t player_id) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "../constants.hpp"
|
#include "../constants.hpp"
|
||||||
#include "../effects/debris_manager.hpp"
|
#include "../effects/debris_manager.hpp"
|
||||||
@@ -23,8 +24,6 @@
|
|||||||
#include "core/system/game_config.hpp"
|
#include "core/system/game_config.hpp"
|
||||||
#include "core/types.hpp"
|
#include "core/types.hpp"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
// Classe principal del joc (escena)
|
// Classe principal del joc (escena)
|
||||||
class EscenaJoc {
|
class EscenaJoc {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -220,9 +220,7 @@ void EscenaLogo::canviar_estat(EstatAnimacio nou_estat) {
|
|||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 g(rd());
|
std::mt19937 g(rd());
|
||||||
std::shuffle(ordre_explosio_.begin(), ordre_explosio_.end(), g);
|
std::shuffle(ordre_explosio_.begin(), ordre_explosio_.end(), g);
|
||||||
}
|
} else if (nou_estat == EstatAnimacio::POST_EXPLOSION) {
|
||||||
else if (nou_estat == EstatAnimacio::POST_EXPLOSION)
|
|
||||||
{
|
|
||||||
Audio::get()->playMusic("title.ogg");
|
Audio::get()->playMusic("title.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "game/effects/debris_manager.hpp"
|
|
||||||
#include "core/defaults.hpp"
|
#include "core/defaults.hpp"
|
||||||
#include "core/graphics/shape.hpp"
|
#include "core/graphics/shape.hpp"
|
||||||
#include "core/input/input_types.hpp"
|
#include "core/input/input_types.hpp"
|
||||||
#include "core/rendering/sdl_manager.hpp"
|
#include "core/rendering/sdl_manager.hpp"
|
||||||
#include "core/system/context_escenes.hpp"
|
#include "core/system/context_escenes.hpp"
|
||||||
#include "core/types.hpp"
|
#include "core/types.hpp"
|
||||||
|
#include "game/effects/debris_manager.hpp"
|
||||||
|
|
||||||
class EscenaLogo {
|
class EscenaLogo {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -140,10 +140,10 @@ void EscenaTitol::inicialitzar_titol() {
|
|||||||
float ancho_sin_escalar = max_x - min_x;
|
float ancho_sin_escalar = max_x - min_x;
|
||||||
float altura_sin_escalar = max_y - min_y;
|
float altura_sin_escalar = max_y - min_y;
|
||||||
|
|
||||||
// Escalar ancho, altura i offset amb ESCALA_TITULO
|
// Escalar ancho, altura i offset amb LOGO_SCALE
|
||||||
float ancho = ancho_sin_escalar * ESCALA_TITULO;
|
float ancho = ancho_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
float altura = altura_sin_escalar * ESCALA_TITULO;
|
float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
float offset_centre = (forma->get_centre().x - min_x) * ESCALA_TITULO;
|
float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
|
|
||||||
lletres_orni_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
|
lletres_orni_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ void EscenaTitol::inicialitzar_titol() {
|
|||||||
|
|
||||||
for (auto& lletra : lletres_orni_) {
|
for (auto& lletra : lletres_orni_) {
|
||||||
lletra.posicio.x = x_actual + lletra.offset_centre;
|
lletra.posicio.x = x_actual + lletra.offset_centre;
|
||||||
lletra.posicio.y = Y_ORNI;
|
lletra.posicio.y = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_POS;
|
||||||
x_actual += lletra.ancho + ESPAI_ENTRE_LLETRES;
|
x_actual += lletra.ancho + ESPAI_ENTRE_LLETRES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,9 @@ void EscenaTitol::inicialitzar_titol() {
|
|||||||
// === Calcular posició Y dinàmica per "ATTACK!" ===
|
// === Calcular posició Y dinàmica per "ATTACK!" ===
|
||||||
// Totes les lletres ORNI tenen la mateixa altura, utilitzem la primera
|
// Totes les lletres ORNI tenen la mateixa altura, utilitzem la primera
|
||||||
float altura_orni = lletres_orni_.empty() ? 50.0f : lletres_orni_[0].altura;
|
float altura_orni = lletres_orni_.empty() ? 50.0f : lletres_orni_[0].altura;
|
||||||
y_attack_dinamica_ = Y_ORNI + altura_orni + SEPARACION_LINEAS;
|
float y_orni = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_POS;
|
||||||
|
float separacion_lineas = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_LINE_SPACING;
|
||||||
|
y_attack_dinamica_ = y_orni + altura_orni + separacion_lineas;
|
||||||
|
|
||||||
std::cout << "[EscenaTitol] Altura ORNI: " << altura_orni
|
std::cout << "[EscenaTitol] Altura ORNI: " << altura_orni
|
||||||
<< " px, Y_ATTACK dinàmica: " << y_attack_dinamica_ << " px\n";
|
<< " px, Y_ATTACK dinàmica: " << y_attack_dinamica_ << " px\n";
|
||||||
@@ -212,10 +214,10 @@ void EscenaTitol::inicialitzar_titol() {
|
|||||||
float ancho_sin_escalar = max_x - min_x;
|
float ancho_sin_escalar = max_x - min_x;
|
||||||
float altura_sin_escalar = max_y - min_y;
|
float altura_sin_escalar = max_y - min_y;
|
||||||
|
|
||||||
// Escalar ancho, altura i offset amb ESCALA_TITULO
|
// Escalar ancho, altura i offset amb LOGO_SCALE
|
||||||
float ancho = ancho_sin_escalar * ESCALA_TITULO;
|
float ancho = ancho_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
float altura = altura_sin_escalar * ESCALA_TITULO;
|
float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
float offset_centre = (forma->get_centre().x - min_x) * ESCALA_TITULO;
|
float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE;
|
||||||
|
|
||||||
lletres_attack_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
|
lletres_attack_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre});
|
||||||
|
|
||||||
@@ -580,7 +582,7 @@ void EscenaTitol::dibuixar() {
|
|||||||
lletres_orni_[i].forma,
|
lletres_orni_[i].forma,
|
||||||
pos_shadow,
|
pos_shadow,
|
||||||
0.0f,
|
0.0f,
|
||||||
ESCALA_TITULO,
|
Defaults::Title::Layout::LOGO_SCALE,
|
||||||
true,
|
true,
|
||||||
1.0f, // progress = 1.0 (totalment visible)
|
1.0f, // progress = 1.0 (totalment visible)
|
||||||
SHADOW_BRIGHTNESS // brightness = 0.4 (brillantor reduïda)
|
SHADOW_BRIGHTNESS // brightness = 0.4 (brillantor reduïda)
|
||||||
@@ -598,7 +600,7 @@ void EscenaTitol::dibuixar() {
|
|||||||
lletres_attack_[i].forma,
|
lletres_attack_[i].forma,
|
||||||
pos_shadow,
|
pos_shadow,
|
||||||
0.0f,
|
0.0f,
|
||||||
ESCALA_TITULO,
|
Defaults::Title::Layout::LOGO_SCALE,
|
||||||
true,
|
true,
|
||||||
1.0f, // progress = 1.0 (totalment visible)
|
1.0f, // progress = 1.0 (totalment visible)
|
||||||
SHADOW_BRIGHTNESS);
|
SHADOW_BRIGHTNESS);
|
||||||
@@ -614,7 +616,7 @@ void EscenaTitol::dibuixar() {
|
|||||||
lletra.forma,
|
lletra.forma,
|
||||||
lletra.posicio,
|
lletra.posicio,
|
||||||
0.0f,
|
0.0f,
|
||||||
ESCALA_TITULO,
|
Defaults::Title::Layout::LOGO_SCALE,
|
||||||
true,
|
true,
|
||||||
1.0f // Brillantor completa
|
1.0f // Brillantor completa
|
||||||
);
|
);
|
||||||
@@ -627,7 +629,7 @@ void EscenaTitol::dibuixar() {
|
|||||||
lletra.forma,
|
lletra.forma,
|
||||||
lletra.posicio,
|
lletra.posicio,
|
||||||
0.0f,
|
0.0f,
|
||||||
ESCALA_TITULO,
|
Defaults::Title::Layout::LOGO_SCALE,
|
||||||
true,
|
true,
|
||||||
1.0f // Brillantor completa
|
1.0f // Brillantor completa
|
||||||
);
|
);
|
||||||
@@ -637,7 +639,7 @@ void EscenaTitol::dibuixar() {
|
|||||||
// En estat MAIN: sempre visible
|
// En estat MAIN: sempre visible
|
||||||
// En estat TRANSITION: parpellejant (blink amb sinusoide)
|
// En estat TRANSITION: parpellejant (blink amb sinusoide)
|
||||||
|
|
||||||
const float spacing = 2.0f; // Espai entre caràcters (usat també per copyright)
|
const float spacing = Defaults::Title::Layout::TEXT_SPACING;
|
||||||
|
|
||||||
bool mostrar_text = true;
|
bool mostrar_text = true;
|
||||||
if (estat_actual_ == EstatTitol::PLAYER_JOIN_PHASE) {
|
if (estat_actual_ == EstatTitol::PLAYER_JOIN_PHASE) {
|
||||||
@@ -648,34 +650,46 @@ void EscenaTitol::dibuixar() {
|
|||||||
|
|
||||||
if (mostrar_text) {
|
if (mostrar_text) {
|
||||||
const std::string main_text = "PRESS START TO PLAY";
|
const std::string main_text = "PRESS START TO PLAY";
|
||||||
const float escala_main = 1.0f;
|
const float escala_main = Defaults::Title::Layout::PRESS_START_SCALE;
|
||||||
|
|
||||||
float text_width = text_.get_text_width(main_text, escala_main, spacing);
|
float text_width = text_.get_text_width(main_text, escala_main, spacing);
|
||||||
|
|
||||||
float x_center = (Defaults::Game::WIDTH - text_width) / 2.0f;
|
float x_center = (Defaults::Game::WIDTH - text_width) / 2.0f;
|
||||||
float altura_attack = lletres_attack_.empty() ? 50.0f : lletres_attack_[0].altura;
|
float y_center = Defaults::Game::HEIGHT * Defaults::Title::Layout::PRESS_START_POS;
|
||||||
float y_center = y_attack_dinamica_ + altura_attack + 70.0f;
|
|
||||||
|
|
||||||
text_.render(main_text, Punt{x_center, y_center}, escala_main, spacing);
|
text_.render(main_text, Punt{x_center, y_center}, escala_main, spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Copyright a la part inferior (centrat horitzontalment) ===
|
// === Copyright a la part inferior (centrat horitzontalment, dues línies) ===
|
||||||
// Convert to uppercase since VectorText only supports A-Z
|
const float escala_copy = Defaults::Title::Layout::COPYRIGHT_SCALE;
|
||||||
std::string copyright = Project::COPYRIGHT;
|
const float copy_height = text_.get_text_height(escala_copy);
|
||||||
for (char& c : copyright) {
|
const float line_spacing = Defaults::Game::HEIGHT * Defaults::Title::Layout::COPYRIGHT_LINE_SPACING;
|
||||||
if (c >= 'a' && c <= 'z') {
|
|
||||||
c = c - 32; // Convert to uppercase
|
// Línea 1: Original (© 1999 Visente i Sergi)
|
||||||
|
std::string copyright_original = Project::COPYRIGHT_ORIGINAL;
|
||||||
|
for (char& c : copyright_original) {
|
||||||
|
if (c >= 'a' && c <= 'z') c = c - 32; // Uppercase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Línea 2: Port (© 2025 jaildesigner)
|
||||||
|
std::string copyright_port = Project::COPYRIGHT_PORT;
|
||||||
|
for (char& c : copyright_port) {
|
||||||
|
if (c >= 'a' && c <= 'z') c = c - 32; // Uppercase
|
||||||
}
|
}
|
||||||
const float escala_copy = 0.6f;
|
|
||||||
|
|
||||||
float copy_width = text_.get_text_width(copyright, escala_copy, spacing);
|
// Calcular posicions (anclatge des del top + separació)
|
||||||
float copy_height = text_.get_text_height(escala_copy);
|
float y_line1 = Defaults::Game::HEIGHT * Defaults::Title::Layout::COPYRIGHT1_POS;
|
||||||
|
float y_line2 = y_line1 + copy_height + line_spacing; // Línea 2 debajo de línea 1
|
||||||
|
|
||||||
float x_copy = (Defaults::Game::WIDTH - copy_width) / 2.0f;
|
// Renderitzar línea 1 (original)
|
||||||
float y_copy = Defaults::Game::HEIGHT - copy_height - 20.0f; // 20px des del fons
|
float width_line1 = text_.get_text_width(copyright_original, escala_copy, spacing);
|
||||||
|
float x_line1 = (Defaults::Game::WIDTH - width_line1) / 2.0f;
|
||||||
|
text_.render(copyright_original, Punt{x_line1, y_line1}, escala_copy, spacing);
|
||||||
|
|
||||||
text_.render(copyright, Punt{x_copy, y_copy}, escala_copy, spacing);
|
// Renderitzar línea 2 (port)
|
||||||
|
float width_line2 = text_.get_text_width(copyright_port, escala_copy, spacing);
|
||||||
|
float x_line2 = (Defaults::Game::WIDTH - width_line2) / 2.0f;
|
||||||
|
text_.render(copyright_port, Punt{x_line2, y_line2}, escala_copy, spacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
// Botones para INICIAR PARTIDA desde MAIN (solo START)
|
// Botones para INICIAR PARTIDA desde MAIN (solo START)
|
||||||
static constexpr std::array<InputAction, 1> START_GAME_BUTTONS = {
|
static constexpr std::array<InputAction, 1> START_GAME_BUTTONS = {
|
||||||
InputAction::START
|
InputAction::START};
|
||||||
};
|
|
||||||
|
|
||||||
class EscenaTitol {
|
class EscenaTitol {
|
||||||
public:
|
public:
|
||||||
@@ -80,10 +79,7 @@ class EscenaTitol {
|
|||||||
static constexpr float DURACIO_FADE_IN = 3.0f; // Duració del fade-in del starfield (1.5 segons)
|
static constexpr float DURACIO_FADE_IN = 3.0f; // Duració del fade-in del starfield (1.5 segons)
|
||||||
static constexpr float DURACIO_INIT = 4.0f; // Duració de l'estat INIT (2 segons)
|
static constexpr float DURACIO_INIT = 4.0f; // Duració de l'estat INIT (2 segons)
|
||||||
static constexpr float DURACIO_TRANSITION = 2.5f; // Duració de la transició (1.5 segons)
|
static constexpr float DURACIO_TRANSITION = 2.5f; // Duració de la transició (1.5 segons)
|
||||||
static constexpr float ESCALA_TITULO = 0.6f; // Escala per les lletres del títol (50%)
|
|
||||||
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espai entre lletres
|
static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espai entre lletres
|
||||||
static constexpr float Y_ORNI = 150.0f; // Posició Y de "ORNI"
|
|
||||||
static constexpr float SEPARACION_LINEAS = 10.0f; // Separació entre "ORNI" i "ATTACK!" (0.0f = pegades)
|
|
||||||
static constexpr float BLINK_FREQUENCY = 3.0f; // Freqüència de parpelleig (3 Hz)
|
static constexpr float BLINK_FREQUENCY = 3.0f; // Freqüència de parpelleig (3 Hz)
|
||||||
static constexpr float DURACIO_BLACK_SCREEN = 2.0f; // Duració pantalla negra (2 segons)
|
static constexpr float DURACIO_BLACK_SCREEN = 2.0f; // Duració pantalla negra (2 segons)
|
||||||
static constexpr int MUSIC_FADE = 1500; // Duracio del fade de la musica del titol al començar a jugar
|
static constexpr int MUSIC_FADE = 1500; // Duracio del fade de la musica del titol al començar a jugar
|
||||||
|
|||||||
@@ -15,47 +15,111 @@ namespace Options {
|
|||||||
|
|
||||||
// Mapa de SDL_Scancode a string
|
// Mapa de SDL_Scancode a string
|
||||||
static const std::unordered_map<SDL_Scancode, std::string> SCANCODE_TO_STRING = {
|
static const std::unordered_map<SDL_Scancode, std::string> SCANCODE_TO_STRING = {
|
||||||
{SDL_SCANCODE_A, "A"}, {SDL_SCANCODE_B, "B"}, {SDL_SCANCODE_C, "C"}, {SDL_SCANCODE_D, "D"},
|
{SDL_SCANCODE_A, "A"},
|
||||||
{SDL_SCANCODE_E, "E"}, {SDL_SCANCODE_F, "F"}, {SDL_SCANCODE_G, "G"}, {SDL_SCANCODE_H, "H"},
|
{SDL_SCANCODE_B, "B"},
|
||||||
{SDL_SCANCODE_I, "I"}, {SDL_SCANCODE_J, "J"}, {SDL_SCANCODE_K, "K"}, {SDL_SCANCODE_L, "L"},
|
{SDL_SCANCODE_C, "C"},
|
||||||
{SDL_SCANCODE_M, "M"}, {SDL_SCANCODE_N, "N"}, {SDL_SCANCODE_O, "O"}, {SDL_SCANCODE_P, "P"},
|
{SDL_SCANCODE_D, "D"},
|
||||||
{SDL_SCANCODE_Q, "Q"}, {SDL_SCANCODE_R, "R"}, {SDL_SCANCODE_S, "S"}, {SDL_SCANCODE_T, "T"},
|
{SDL_SCANCODE_E, "E"},
|
||||||
{SDL_SCANCODE_U, "U"}, {SDL_SCANCODE_V, "V"}, {SDL_SCANCODE_W, "W"}, {SDL_SCANCODE_X, "X"},
|
{SDL_SCANCODE_F, "F"},
|
||||||
{SDL_SCANCODE_Y, "Y"}, {SDL_SCANCODE_Z, "Z"},
|
{SDL_SCANCODE_G, "G"},
|
||||||
{SDL_SCANCODE_1, "1"}, {SDL_SCANCODE_2, "2"}, {SDL_SCANCODE_3, "3"}, {SDL_SCANCODE_4, "4"},
|
{SDL_SCANCODE_H, "H"},
|
||||||
{SDL_SCANCODE_5, "5"}, {SDL_SCANCODE_6, "6"}, {SDL_SCANCODE_7, "7"}, {SDL_SCANCODE_8, "8"},
|
{SDL_SCANCODE_I, "I"},
|
||||||
{SDL_SCANCODE_9, "9"}, {SDL_SCANCODE_0, "0"},
|
{SDL_SCANCODE_J, "J"},
|
||||||
{SDL_SCANCODE_RETURN, "RETURN"}, {SDL_SCANCODE_ESCAPE, "ESCAPE"},
|
{SDL_SCANCODE_K, "K"},
|
||||||
{SDL_SCANCODE_BACKSPACE, "BACKSPACE"}, {SDL_SCANCODE_TAB, "TAB"},
|
{SDL_SCANCODE_L, "L"},
|
||||||
|
{SDL_SCANCODE_M, "M"},
|
||||||
|
{SDL_SCANCODE_N, "N"},
|
||||||
|
{SDL_SCANCODE_O, "O"},
|
||||||
|
{SDL_SCANCODE_P, "P"},
|
||||||
|
{SDL_SCANCODE_Q, "Q"},
|
||||||
|
{SDL_SCANCODE_R, "R"},
|
||||||
|
{SDL_SCANCODE_S, "S"},
|
||||||
|
{SDL_SCANCODE_T, "T"},
|
||||||
|
{SDL_SCANCODE_U, "U"},
|
||||||
|
{SDL_SCANCODE_V, "V"},
|
||||||
|
{SDL_SCANCODE_W, "W"},
|
||||||
|
{SDL_SCANCODE_X, "X"},
|
||||||
|
{SDL_SCANCODE_Y, "Y"},
|
||||||
|
{SDL_SCANCODE_Z, "Z"},
|
||||||
|
{SDL_SCANCODE_1, "1"},
|
||||||
|
{SDL_SCANCODE_2, "2"},
|
||||||
|
{SDL_SCANCODE_3, "3"},
|
||||||
|
{SDL_SCANCODE_4, "4"},
|
||||||
|
{SDL_SCANCODE_5, "5"},
|
||||||
|
{SDL_SCANCODE_6, "6"},
|
||||||
|
{SDL_SCANCODE_7, "7"},
|
||||||
|
{SDL_SCANCODE_8, "8"},
|
||||||
|
{SDL_SCANCODE_9, "9"},
|
||||||
|
{SDL_SCANCODE_0, "0"},
|
||||||
|
{SDL_SCANCODE_RETURN, "RETURN"},
|
||||||
|
{SDL_SCANCODE_ESCAPE, "ESCAPE"},
|
||||||
|
{SDL_SCANCODE_BACKSPACE, "BACKSPACE"},
|
||||||
|
{SDL_SCANCODE_TAB, "TAB"},
|
||||||
{SDL_SCANCODE_SPACE, "SPACE"},
|
{SDL_SCANCODE_SPACE, "SPACE"},
|
||||||
{SDL_SCANCODE_UP, "UP"}, {SDL_SCANCODE_DOWN, "DOWN"},
|
{SDL_SCANCODE_UP, "UP"},
|
||||||
{SDL_SCANCODE_LEFT, "LEFT"}, {SDL_SCANCODE_RIGHT, "RIGHT"},
|
{SDL_SCANCODE_DOWN, "DOWN"},
|
||||||
{SDL_SCANCODE_LSHIFT, "LSHIFT"}, {SDL_SCANCODE_RSHIFT, "RSHIFT"},
|
{SDL_SCANCODE_LEFT, "LEFT"},
|
||||||
{SDL_SCANCODE_LCTRL, "LCTRL"}, {SDL_SCANCODE_RCTRL, "RCTRL"},
|
{SDL_SCANCODE_RIGHT, "RIGHT"},
|
||||||
{SDL_SCANCODE_LALT, "LALT"}, {SDL_SCANCODE_RALT, "RALT"}
|
{SDL_SCANCODE_LSHIFT, "LSHIFT"},
|
||||||
};
|
{SDL_SCANCODE_RSHIFT, "RSHIFT"},
|
||||||
|
{SDL_SCANCODE_LCTRL, "LCTRL"},
|
||||||
|
{SDL_SCANCODE_RCTRL, "RCTRL"},
|
||||||
|
{SDL_SCANCODE_LALT, "LALT"},
|
||||||
|
{SDL_SCANCODE_RALT, "RALT"}};
|
||||||
|
|
||||||
// Mapa invers: string a SDL_Scancode
|
// Mapa invers: string a SDL_Scancode
|
||||||
static const std::unordered_map<std::string, SDL_Scancode> STRING_TO_SCANCODE = {
|
static const std::unordered_map<std::string, SDL_Scancode> STRING_TO_SCANCODE = {
|
||||||
{"A", SDL_SCANCODE_A}, {"B", SDL_SCANCODE_B}, {"C", SDL_SCANCODE_C}, {"D", SDL_SCANCODE_D},
|
{"A", SDL_SCANCODE_A},
|
||||||
{"E", SDL_SCANCODE_E}, {"F", SDL_SCANCODE_F}, {"G", SDL_SCANCODE_G}, {"H", SDL_SCANCODE_H},
|
{"B", SDL_SCANCODE_B},
|
||||||
{"I", SDL_SCANCODE_I}, {"J", SDL_SCANCODE_J}, {"K", SDL_SCANCODE_K}, {"L", SDL_SCANCODE_L},
|
{"C", SDL_SCANCODE_C},
|
||||||
{"M", SDL_SCANCODE_M}, {"N", SDL_SCANCODE_N}, {"O", SDL_SCANCODE_O}, {"P", SDL_SCANCODE_P},
|
{"D", SDL_SCANCODE_D},
|
||||||
{"Q", SDL_SCANCODE_Q}, {"R", SDL_SCANCODE_R}, {"S", SDL_SCANCODE_S}, {"T", SDL_SCANCODE_T},
|
{"E", SDL_SCANCODE_E},
|
||||||
{"U", SDL_SCANCODE_U}, {"V", SDL_SCANCODE_V}, {"W", SDL_SCANCODE_W}, {"X", SDL_SCANCODE_X},
|
{"F", SDL_SCANCODE_F},
|
||||||
{"Y", SDL_SCANCODE_Y}, {"Z", SDL_SCANCODE_Z},
|
{"G", SDL_SCANCODE_G},
|
||||||
{"1", SDL_SCANCODE_1}, {"2", SDL_SCANCODE_2}, {"3", SDL_SCANCODE_3}, {"4", SDL_SCANCODE_4},
|
{"H", SDL_SCANCODE_H},
|
||||||
{"5", SDL_SCANCODE_5}, {"6", SDL_SCANCODE_6}, {"7", SDL_SCANCODE_7}, {"8", SDL_SCANCODE_8},
|
{"I", SDL_SCANCODE_I},
|
||||||
{"9", SDL_SCANCODE_9}, {"0", SDL_SCANCODE_0},
|
{"J", SDL_SCANCODE_J},
|
||||||
{"RETURN", SDL_SCANCODE_RETURN}, {"ESCAPE", SDL_SCANCODE_ESCAPE},
|
{"K", SDL_SCANCODE_K},
|
||||||
{"BACKSPACE", SDL_SCANCODE_BACKSPACE}, {"TAB", SDL_SCANCODE_TAB},
|
{"L", SDL_SCANCODE_L},
|
||||||
|
{"M", SDL_SCANCODE_M},
|
||||||
|
{"N", SDL_SCANCODE_N},
|
||||||
|
{"O", SDL_SCANCODE_O},
|
||||||
|
{"P", SDL_SCANCODE_P},
|
||||||
|
{"Q", SDL_SCANCODE_Q},
|
||||||
|
{"R", SDL_SCANCODE_R},
|
||||||
|
{"S", SDL_SCANCODE_S},
|
||||||
|
{"T", SDL_SCANCODE_T},
|
||||||
|
{"U", SDL_SCANCODE_U},
|
||||||
|
{"V", SDL_SCANCODE_V},
|
||||||
|
{"W", SDL_SCANCODE_W},
|
||||||
|
{"X", SDL_SCANCODE_X},
|
||||||
|
{"Y", SDL_SCANCODE_Y},
|
||||||
|
{"Z", SDL_SCANCODE_Z},
|
||||||
|
{"1", SDL_SCANCODE_1},
|
||||||
|
{"2", SDL_SCANCODE_2},
|
||||||
|
{"3", SDL_SCANCODE_3},
|
||||||
|
{"4", SDL_SCANCODE_4},
|
||||||
|
{"5", SDL_SCANCODE_5},
|
||||||
|
{"6", SDL_SCANCODE_6},
|
||||||
|
{"7", SDL_SCANCODE_7},
|
||||||
|
{"8", SDL_SCANCODE_8},
|
||||||
|
{"9", SDL_SCANCODE_9},
|
||||||
|
{"0", SDL_SCANCODE_0},
|
||||||
|
{"RETURN", SDL_SCANCODE_RETURN},
|
||||||
|
{"ESCAPE", SDL_SCANCODE_ESCAPE},
|
||||||
|
{"BACKSPACE", SDL_SCANCODE_BACKSPACE},
|
||||||
|
{"TAB", SDL_SCANCODE_TAB},
|
||||||
{"SPACE", SDL_SCANCODE_SPACE},
|
{"SPACE", SDL_SCANCODE_SPACE},
|
||||||
{"UP", SDL_SCANCODE_UP}, {"DOWN", SDL_SCANCODE_DOWN},
|
{"UP", SDL_SCANCODE_UP},
|
||||||
{"LEFT", SDL_SCANCODE_LEFT}, {"RIGHT", SDL_SCANCODE_RIGHT},
|
{"DOWN", SDL_SCANCODE_DOWN},
|
||||||
{"LSHIFT", SDL_SCANCODE_LSHIFT}, {"RSHIFT", SDL_SCANCODE_RSHIFT},
|
{"LEFT", SDL_SCANCODE_LEFT},
|
||||||
{"LCTRL", SDL_SCANCODE_LCTRL}, {"RCTRL", SDL_SCANCODE_RCTRL},
|
{"RIGHT", SDL_SCANCODE_RIGHT},
|
||||||
{"LALT", SDL_SCANCODE_LALT}, {"RALT", SDL_SCANCODE_RALT}
|
{"LSHIFT", SDL_SCANCODE_LSHIFT},
|
||||||
};
|
{"RSHIFT", SDL_SCANCODE_RSHIFT},
|
||||||
|
{"LCTRL", SDL_SCANCODE_LCTRL},
|
||||||
|
{"RCTRL", SDL_SCANCODE_RCTRL},
|
||||||
|
{"LALT", SDL_SCANCODE_LALT},
|
||||||
|
{"RALT", SDL_SCANCODE_RALT}};
|
||||||
|
|
||||||
// Mapa de botó de gamepad (int) a string
|
// Mapa de botó de gamepad (int) a string
|
||||||
static const std::unordered_map<int, std::string> BUTTON_TO_STRING = {
|
static const std::unordered_map<int, std::string> BUTTON_TO_STRING = {
|
||||||
@@ -90,8 +154,7 @@ static const std::unordered_map<std::string, int> STRING_TO_BUTTON = {
|
|||||||
{"DPAD_LEFT", SDL_GAMEPAD_BUTTON_DPAD_LEFT},
|
{"DPAD_LEFT", SDL_GAMEPAD_BUTTON_DPAD_LEFT},
|
||||||
{"DPAD_RIGHT", SDL_GAMEPAD_BUTTON_DPAD_RIGHT},
|
{"DPAD_RIGHT", SDL_GAMEPAD_BUTTON_DPAD_RIGHT},
|
||||||
{"L2_AS_BUTTON", 100},
|
{"L2_AS_BUTTON", 100},
|
||||||
{"R2_AS_BUTTON", 101}
|
{"R2_AS_BUTTON", 101}};
|
||||||
};
|
|
||||||
|
|
||||||
static auto scancodeToString(SDL_Scancode code) -> std::string {
|
static auto scancodeToString(SDL_Scancode code) -> std::string {
|
||||||
auto it = SCANCODE_TO_STRING.find(code);
|
auto it = SCANCODE_TO_STRING.find(code);
|
||||||
@@ -115,7 +178,6 @@ static auto stringToButton(const std::string& str) -> int {
|
|||||||
|
|
||||||
// ========== FI FUNCIONS AUXILIARS ==========
|
// ========== FI FUNCIONS AUXILIARS ==========
|
||||||
|
|
||||||
|
|
||||||
// Inicialitzar opcions amb valors per defecte de Defaults::
|
// Inicialitzar opcions amb valors per defecte de Defaults::
|
||||||
void init() {
|
void init() {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
namespace StageSystem {
|
namespace StageSystem {
|
||||||
|
|
||||||
SpawnController::SpawnController()
|
SpawnController::SpawnController()
|
||||||
: config_(nullptr), temps_transcorregut_(0.0f), index_spawn_actual_(0), ship_position_(nullptr) {}
|
: config_(nullptr),
|
||||||
|
temps_transcorregut_(0.0f),
|
||||||
|
index_spawn_actual_(0),
|
||||||
|
ship_position_(nullptr) {}
|
||||||
|
|
||||||
void SpawnController::configurar(const ConfigStage* config) {
|
void SpawnController::configurar(const ConfigStage* config) {
|
||||||
config_ = config;
|
config_ = config;
|
||||||
|
|||||||
@@ -91,10 +91,9 @@ namespace Constants {
|
|||||||
"SENSORS DETECT HOSTILE ORNIS...",
|
"SENSORS DETECT HOSTILE ORNIS...",
|
||||||
"UNIDENTIFIED ROLLING OBJECTS INBOUND!",
|
"UNIDENTIFIED ROLLING OBJECTS INBOUND!",
|
||||||
"ENEMY FORCES MOBILIZING!",
|
"ENEMY FORCES MOBILIZING!",
|
||||||
"PREPARE FOR IMPACT!"
|
"PREPARE FOR IMPACT!"};
|
||||||
};
|
|
||||||
|
|
||||||
constexpr const char* MISSATGE_LEVEL_COMPLETED = "GOOD JOB COMMANDER!";
|
constexpr const char* MISSATGE_LEVEL_COMPLETED = "GOOD JOB COMMANDER!";
|
||||||
}
|
} // namespace Constants
|
||||||
|
|
||||||
} // namespace StageSystem
|
} // namespace StageSystem
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
#include "stage_loader.hpp"
|
#include "stage_loader.hpp"
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
|
||||||
#include "external/fkyaml_node.hpp"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "core/resources/resource_helper.hpp"
|
||||||
|
#include "external/fkyaml_node.hpp"
|
||||||
|
|
||||||
namespace StageSystem {
|
namespace StageSystem {
|
||||||
|
|
||||||
std::unique_ptr<ConfigSistemaStages> StageLoader::carregar(const std::string& path) {
|
std::unique_ptr<ConfigSistemaStages> StageLoader::carregar(const std::string& path) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
#include "stage_config.hpp"
|
#include "stage_config.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void ShipAnimator::configurar_nau_p1(NauTitol& nau) {
|
|||||||
nau.temps_estat = 0.0f;
|
nau.temps_estat = 0.0f;
|
||||||
|
|
||||||
// Posicions (clock 8, bottom-left)
|
// Posicions (clock 8, bottom-left)
|
||||||
nau.posicio_objectiu = {P1_TARGET_X, P1_TARGET_Y};
|
nau.posicio_objectiu = {P1_TARGET_X(), P1_TARGET_Y()};
|
||||||
|
|
||||||
// Calcular posició inicial (fora de pantalla)
|
// Calcular posició inicial (fora de pantalla)
|
||||||
nau.posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_8_ANGLE);
|
nau.posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_8_ANGLE);
|
||||||
@@ -262,7 +262,7 @@ void ShipAnimator::configurar_nau_p2(NauTitol& nau) {
|
|||||||
nau.temps_estat = 0.0f;
|
nau.temps_estat = 0.0f;
|
||||||
|
|
||||||
// Posicions (clock 4, bottom-right)
|
// Posicions (clock 4, bottom-right)
|
||||||
nau.posicio_objectiu = {P2_TARGET_X, P2_TARGET_Y};
|
nau.posicio_objectiu = {P2_TARGET_X(), P2_TARGET_Y()};
|
||||||
|
|
||||||
// Calcular posició inicial (fora de pantalla)
|
// Calcular posició inicial (fora de pantalla)
|
||||||
nau.posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_4_ANGLE);
|
nau.posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_4_ANGLE);
|
||||||
@@ -293,7 +293,8 @@ Punt ShipAnimator::calcular_posicio_fora_pantalla(float angle_rellotge) const {
|
|||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
// Convertir angle del rellotge a radians (per exemple: 240° per clock 8)
|
// Convertir angle del rellotge a radians (per exemple: 240° per clock 8)
|
||||||
// Calcular posició en direcció radial des del centre, però més lluny (+ ENTRY_OFFSET)
|
// Calcular posició en direcció radial des del centre, però més lluny
|
||||||
|
// ENTRY_OFFSET es calcula automàticament: (SHIP_MAX_RADIUS * ENTRY_SCALE_START) + ENTRY_OFFSET_MARGIN
|
||||||
float extended_radius = CLOCK_RADIUS + ENTRY_OFFSET;
|
float extended_radius = CLOCK_RADIUS + ENTRY_OFFSET;
|
||||||
|
|
||||||
float x = Defaults::Game::WIDTH / 2.0f + extended_radius * std::cos(angle_rellotge);
|
float x = Defaults::Game::WIDTH / 2.0f + extended_radius * std::cos(angle_rellotge);
|
||||||
|
|||||||
@@ -5,5 +5,7 @@ constexpr const char* NAME = "@PROJECT_NAME@";
|
|||||||
constexpr const char* LONG_NAME = "@PROJECT_LONG_NAME@";
|
constexpr const char* LONG_NAME = "@PROJECT_LONG_NAME@";
|
||||||
constexpr const char* VERSION = "@PROJECT_VERSION@";
|
constexpr const char* VERSION = "@PROJECT_VERSION@";
|
||||||
constexpr const char* COPYRIGHT = "@PROJECT_COPYRIGHT@";
|
constexpr const char* COPYRIGHT = "@PROJECT_COPYRIGHT@";
|
||||||
|
constexpr const char* COPYRIGHT_ORIGINAL = "@PROJECT_COPYRIGHT_ORIGINAL@";
|
||||||
|
constexpr const char* COPYRIGHT_PORT = "@PROJECT_COPYRIGHT_PORT@";
|
||||||
constexpr const char* GIT_HASH = "@GIT_HASH@";
|
constexpr const char* GIT_HASH = "@GIT_HASH@";
|
||||||
} // namespace Project
|
} // namespace Project
|
||||||
|
|||||||
Reference in New Issue
Block a user