Lint: rename de métodos privados (camelBack + traducción al inglés)
Tanda grande de identifier-naming: 47 métodos privados pasan de snake_case (en su mayoría catalán/spanish) a camelBack inglés. Solo afecta a sus archivos hpp+cpp; ningún símbolo cruza fichero (los públicos quedan para una pasada manual con VS Code). Renames por clase: - ShapeLoader: resolve_path → resolvePath. - VectorText: load_charset → loadCharset, get_shape_filename → getShapeFilename. - Shape: starts_with → startsWith (cuidado de no tocar std::string::starts_with que también usaba), extract_value → extractValue, parse_center → parseCenter, parse_points → parsePoints. - Starfield: inicialitzar_estrella → initStar, fora_area → isOutsideArea, calcular_escala → computeScale, calcular_brightness → computeBrightness. - TitleScene: actualitzar_animacio_logo → updateLogoAnimation, inicialitzar_titol → initTitle. - LogoScene: inicialitzar_lletres → initLetters, actualitzar_explosions → updateExplosions, canviar_estat → changeState, totes_lletres_completes → allLettersComplete. - SpawnController: generar_spawn_events → generateSpawnEvents, seleccionar_tipus_aleatori → selectRandomType, spawn_enemic → spawnEnemy, aplicar_multiplicadors → applyMultipliers. - ShipAnimator: actualitzar_entering/floating/exiting → updateEntering/Floating/Exiting, configurar_nau_p1/p2 → configureShipP1/P2, calcular_posicio_fora_pantalla → computeOffscreenPosition. - GameScene: dibuixar_marges → drawMargins, dibuixar_marcador → drawScoreboard, disparar_bala → fireBullet, obtenir_punt_spawn → getSpawnPoint, unir_jugador → joinPlayer, dibuixar_continue → drawContinue, dibuixar_missatge_stage → drawStageMessage. - StageLoader: parse_metadata/stage/spawn_config/distribution/multipliers/ spawn_mode → parseMetadata/Stage/SpawnConfig/Distribution/Multipliers/ SpawnMode, validar_config → validateConfig. - StageManager: canviar_estat → changeState, processar_init_hud/level_start/playing/level_completed → processInitHud/LevelStart/Playing/LevelCompleted, carregar_stage → loadStage. Métodos públicos y funciones libres (cross-file) quedan a propósito sin tocar — los renombrará el usuario con la herramienta de rename de VS Code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,13 +23,13 @@ namespace {
|
|||||||
// Cachés locales: indexados por nombre lógico ("title.ogg", "effects/laser_shoot.wav", etc.)
|
// Cachés locales: indexados por nombre lógico ("title.ogg", "effects/laser_shoot.wav", etc.)
|
||||||
// Mantienen ownership con unique_ptr; se liberan al salir del programa.
|
// Mantienen ownership con unique_ptr; se liberan al salir del programa.
|
||||||
auto musicCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Music>>& {
|
auto musicCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Music>>& {
|
||||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache;
|
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache_;
|
||||||
return cache;
|
return cache_;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto soundCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& {
|
auto soundCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& {
|
||||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache;
|
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache_;
|
||||||
return cache;
|
return cache_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normaliza el nombre añadiendo la subcarpeta correspondiente si no la trae:
|
// Normaliza el nombre añadiendo la subcarpeta correspondiente si no la trae:
|
||||||
|
|||||||
@@ -49,27 +49,27 @@ auto Shape::parseFile(const std::string& contingut) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse command
|
// Parse command
|
||||||
if (starts_with(line, "name:")) {
|
if (startsWith(line, "name:")) {
|
||||||
nom_ = trim(extract_value(line));
|
nom_ = trim(extractValue(line));
|
||||||
} else if (starts_with(line, "scale:")) {
|
} else if (startsWith(line, "scale:")) {
|
||||||
try {
|
try {
|
||||||
escala_defecte_ = std::stof(extract_value(line));
|
escala_defecte_ = std::stof(extractValue(line));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
std::cerr << "[Shape] Warning: scale invàlida, usant 1.0" << '\n';
|
std::cerr << "[Shape] Warning: scale invàlida, usant 1.0" << '\n';
|
||||||
escala_defecte_ = 1.0F;
|
escala_defecte_ = 1.0F;
|
||||||
}
|
}
|
||||||
} else if (starts_with(line, "center:")) {
|
} else if (startsWith(line, "center:")) {
|
||||||
parse_center(extract_value(line));
|
parseCenter(extractValue(line));
|
||||||
} else if (starts_with(line, "polyline:")) {
|
} else if (startsWith(line, "polyline:")) {
|
||||||
auto points = parse_points(extract_value(line));
|
auto points = parsePoints(extractValue(line));
|
||||||
if (points.size() >= 2) {
|
if (points.size() >= 2) {
|
||||||
primitives_.push_back({PrimitiveType::POLYLINE, points});
|
primitives_.push_back({PrimitiveType::POLYLINE, points});
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "[Shape] Warning: polyline con menys de 2 points ignorada"
|
std::cerr << "[Shape] Warning: polyline con menys de 2 points ignorada"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
} else if (starts_with(line, "line:")) {
|
} else if (startsWith(line, "line:")) {
|
||||||
auto points = parse_points(extract_value(line));
|
auto points = parsePoints(extractValue(line));
|
||||||
if (points.size() == 2) {
|
if (points.size() == 2) {
|
||||||
primitives_.push_back({PrimitiveType::LINE, points});
|
primitives_.push_back({PrimitiveType::LINE, points});
|
||||||
} else {
|
} else {
|
||||||
@@ -100,8 +100,8 @@ auto Shape::trim(const std::string& str) const -> std::string {
|
|||||||
return str.substr(start, end - start + 1);
|
return str.substr(start, end - start + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper: starts_with
|
// Helper: startsWith
|
||||||
auto Shape::starts_with(const std::string& str,
|
auto Shape::startsWith(const std::string& str,
|
||||||
const std::string& prefix) const -> bool {
|
const std::string& prefix) const -> bool {
|
||||||
if (str.length() < prefix.length()) {
|
if (str.length() < prefix.length()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -110,7 +110,7 @@ auto Shape::starts_with(const std::string& str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: extract value after ':'
|
// Helper: extract value after ':'
|
||||||
auto Shape::extract_value(const std::string& line) const -> std::string {
|
auto Shape::extractValue(const std::string& line) const -> std::string {
|
||||||
size_t colon = line.find(':');
|
size_t colon = line.find(':');
|
||||||
if (colon == std::string::npos) {
|
if (colon == std::string::npos) {
|
||||||
return "";
|
return "";
|
||||||
@@ -119,7 +119,7 @@ auto Shape::extract_value(const std::string& line) const -> std::string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: parse center "x, y"
|
// Helper: parse center "x, y"
|
||||||
void Shape::parse_center(const std::string& value) {
|
void Shape::parseCenter(const std::string& value) {
|
||||||
std::string val = trim(value);
|
std::string val = trim(value);
|
||||||
size_t comma = val.find(',');
|
size_t comma = val.find(',');
|
||||||
if (comma != std::string::npos) {
|
if (comma != std::string::npos) {
|
||||||
@@ -134,7 +134,7 @@ void Shape::parse_center(const std::string& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
||||||
auto Shape::parse_points(const std::string& str) const -> std::vector<Vec2> {
|
auto Shape::parsePoints(const std::string& str) const -> std::vector<Vec2> {
|
||||||
std::vector<Vec2> points;
|
std::vector<Vec2> points;
|
||||||
std::istringstream iss(trim(str));
|
std::istringstream iss(trim(str));
|
||||||
std::string pair;
|
std::string pair;
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ class Shape {
|
|||||||
|
|
||||||
// Helpers privats per parsejar
|
// Helpers privats per parsejar
|
||||||
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
||||||
[[nodiscard]] auto starts_with(const std::string& str, const std::string& prefix) const -> bool;
|
[[nodiscard]] auto startsWith(const std::string& str, const std::string& prefix) const -> bool;
|
||||||
[[nodiscard]] auto extract_value(const std::string& line) const -> std::string;
|
[[nodiscard]] auto extractValue(const std::string& line) const -> std::string;
|
||||||
void parse_center(const std::string& value);
|
void parseCenter(const std::string& value);
|
||||||
[[nodiscard]] auto parse_points(const std::string& str) const -> std::vector<Vec2>;
|
[[nodiscard]] auto parsePoints(const std::string& str) const -> std::vector<Vec2>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void ShapeLoader::clear_cache() {
|
|||||||
|
|
||||||
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
||||||
|
|
||||||
auto ShapeLoader::resolve_path(const std::string& filename) -> std::string {
|
auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
// Si es un path absolut (comença con '/'), usar-lo directament
|
||||||
if (!filename.empty() && filename[0] == '/') {
|
if (!filename.empty() && filename[0] == '/') {
|
||||||
return filename;
|
return filename;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ShapeLoader {
|
|||||||
static std::string base_path_; // "data/shapes/"
|
static std::string base_path_; // "data/shapes/"
|
||||||
|
|
||||||
// Helpers privats
|
// Helpers privats
|
||||||
static auto resolve_path(const std::string& filename) -> std::string;
|
static auto resolvePath(const std::string& filename) -> std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ Starfield::Starfield(Rendering::Renderer* renderer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicialitzar una estrella (nueva o regenerada)
|
// Inicialitzar una estrella (nueva o regenerada)
|
||||||
void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
void Starfield::initStar(Estrella& estrella) const {
|
||||||
// Angle aleatori des del point de fuga hacia fuera
|
// Angle aleatori des del point de fuga hacia fuera
|
||||||
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
|
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verificar si una estrella está fuera de l'àrea
|
// Verificar si una estrella está fuera de l'àrea
|
||||||
auto Starfield::fora_area(const Estrella& estrella) const -> bool {
|
auto Starfield::isOutsideArea(const Estrella& estrella) const -> bool {
|
||||||
return (estrella.position.x < area_.x ||
|
return (estrella.position.x < area_.x ||
|
||||||
estrella.position.x > area_.x + area_.w ||
|
estrella.position.x > area_.x + area_.w ||
|
||||||
estrella.position.y < area_.y ||
|
estrella.position.y < area_.y ||
|
||||||
@@ -88,7 +88,7 @@ auto Starfield::fora_area(const Estrella& estrella) const -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcular scale dinàmica segons distancia del centro
|
// Calcular scale dinàmica segons distancia del centro
|
||||||
auto Starfield::calcular_escala(const Estrella& estrella) const -> float {
|
auto Starfield::computeScale(const Estrella& estrella) const -> float {
|
||||||
const CapaConfig& capa = capes_[estrella.capa];
|
const CapaConfig& capa = capes_[estrella.capa];
|
||||||
|
|
||||||
// Interpolació lineal basada en distancia del centro
|
// Interpolació lineal basada en distancia del centro
|
||||||
@@ -98,7 +98,7 @@ auto Starfield::calcular_escala(const Estrella& estrella) const -> float {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcular brightness dinàmica segons distancia del centro
|
// Calcular brightness dinàmica segons distancia del centro
|
||||||
auto Starfield::calcular_brightness(const Estrella& estrella) const -> float {
|
auto Starfield::computeBrightness(const Estrella& estrella) const -> float {
|
||||||
// Interpolació lineal: estrelles properes (vora) més brillants
|
// Interpolació lineal: estrelles properes (vora) més brillants
|
||||||
// distancia_centre: 0.0 (centro, llunyanes) → 1.0 (vora, properes)
|
// distancia_centre: 0.0 (centro, llunyanes) → 1.0 (vora, properes)
|
||||||
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
||||||
@@ -130,8 +130,8 @@ void Starfield::update(float delta_time) {
|
|||||||
estrella.distancia_centre = dist_px / radi_max_;
|
estrella.distancia_centre = dist_px / radi_max_;
|
||||||
|
|
||||||
// Si ha sortit de l'àrea, regenerar-la
|
// Si ha sortit de l'àrea, regenerar-la
|
||||||
if (fora_area(estrella)) {
|
if (isOutsideArea(estrella)) {
|
||||||
inicialitzar_estrella(estrella);
|
initStar(estrella);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,8 @@ void Starfield::draw() {
|
|||||||
|
|
||||||
for (const auto& estrella : estrelles_) {
|
for (const auto& estrella : estrelles_) {
|
||||||
// Calcular scale i brightness dinàmicament
|
// Calcular scale i brightness dinàmicament
|
||||||
float scale = calcular_escala(estrella);
|
float scale = computeScale(estrella);
|
||||||
float brightness = calcular_brightness(estrella);
|
float brightness = computeBrightness(estrella);
|
||||||
|
|
||||||
// Renderizar estrella sin rotación
|
// Renderizar estrella sin rotación
|
||||||
Rendering::render_shape(
|
Rendering::render_shape(
|
||||||
|
|||||||
@@ -56,16 +56,16 @@ class Starfield {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Inicialitzar una estrella (nueva o regenerada)
|
// Inicialitzar una estrella (nueva o regenerada)
|
||||||
void inicialitzar_estrella(Estrella& estrella) const;
|
void initStar(Estrella& estrella) const;
|
||||||
|
|
||||||
// Verificar si una estrella está fuera de l'àrea
|
// Verificar si una estrella está fuera de l'àrea
|
||||||
[[nodiscard]] auto fora_area(const Estrella& estrella) const -> bool;
|
[[nodiscard]] auto isOutsideArea(const Estrella& estrella) const -> bool;
|
||||||
|
|
||||||
// Calcular scale dinàmica segons distancia del centro
|
// Calcular scale dinàmica segons distancia del centro
|
||||||
[[nodiscard]] auto calcular_escala(const Estrella& estrella) const -> float;
|
[[nodiscard]] auto computeScale(const Estrella& estrella) const -> float;
|
||||||
|
|
||||||
// Calcular brightness dinàmica segons distancia del centro
|
// Calcular brightness dinàmica segons distancia del centro
|
||||||
[[nodiscard]] auto calcular_brightness(const Estrella& estrella) const -> float;
|
[[nodiscard]] auto computeBrightness(const Estrella& estrella) const -> float;
|
||||||
|
|
||||||
// Dades
|
// Dades
|
||||||
std::vector<Estrella> estrelles_;
|
std::vector<Estrella> estrelles_;
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ constexpr float BASE_CHAR_HEIGHT = 40.0F; // Altura base del caràcter
|
|||||||
|
|
||||||
VectorText::VectorText(Rendering::Renderer* renderer)
|
VectorText::VectorText(Rendering::Renderer* renderer)
|
||||||
: renderer_(renderer) {
|
: renderer_(renderer) {
|
||||||
load_charset();
|
loadCharset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VectorText::load_charset() {
|
void VectorText::loadCharset() {
|
||||||
// Cargar dígitos 0-9
|
// Cargar dígitos 0-9
|
||||||
for (char c = '0'; c <= '9'; c++) {
|
for (char c = '0'; c <= '9'; c++) {
|
||||||
std::string filename = get_shape_filename(c);
|
std::string filename = getShapeFilename(c);
|
||||||
auto shape = ShapeLoader::load(filename);
|
auto shape = ShapeLoader::load(filename);
|
||||||
|
|
||||||
if (shape && shape->isValid()) {
|
if (shape && shape->isValid()) {
|
||||||
@@ -35,7 +35,7 @@ void VectorText::load_charset() {
|
|||||||
|
|
||||||
// Cargar lletres A-Z (majúscules)
|
// Cargar lletres A-Z (majúscules)
|
||||||
for (char c = 'A'; c <= 'Z'; c++) {
|
for (char c = 'A'; c <= 'Z'; c++) {
|
||||||
std::string filename = get_shape_filename(c);
|
std::string filename = getShapeFilename(c);
|
||||||
auto shape = ShapeLoader::load(filename);
|
auto shape = ShapeLoader::load(filename);
|
||||||
|
|
||||||
if (shape && shape->isValid()) {
|
if (shape && shape->isValid()) {
|
||||||
@@ -50,7 +50,7 @@ void VectorText::load_charset() {
|
|||||||
const std::string SYMBOLS[] = {".", ",", "-", ":", "!", "?"};
|
const std::string SYMBOLS[] = {".", ",", "-", ":", "!", "?"};
|
||||||
for (const auto& sym : SYMBOLS) {
|
for (const auto& sym : SYMBOLS) {
|
||||||
char c = sym[0];
|
char c = sym[0];
|
||||||
std::string filename = get_shape_filename(c);
|
std::string filename = getShapeFilename(c);
|
||||||
auto shape = ShapeLoader::load(filename);
|
auto shape = ShapeLoader::load(filename);
|
||||||
|
|
||||||
if (shape && shape->isValid()) {
|
if (shape && shape->isValid()) {
|
||||||
@@ -79,7 +79,7 @@ void VectorText::load_charset() {
|
|||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
auto VectorText::get_shape_filename(char c) const -> std::string {
|
auto VectorText::getShapeFilename(char c) const -> std::string {
|
||||||
// Mapeo carácter → nombre de archivo (con prefix "font/").
|
// Mapeo carácter → nombre de archivo (con prefix "font/").
|
||||||
// Dígitos 0-9 y mayúsculas A-Z comparten el mismo path: la shape se llama
|
// Dígitos 0-9 y mayúsculas A-Z comparten el mismo path: la shape se llama
|
||||||
// como el caracter mismo, así que se agrupan en un único case.
|
// como el caracter mismo, así que se agrupan en un único case.
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ class VectorText {
|
|||||||
Rendering::Renderer* renderer_;
|
Rendering::Renderer* renderer_;
|
||||||
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
||||||
|
|
||||||
void load_charset();
|
void loadCharset();
|
||||||
[[nodiscard]] auto get_shape_filename(char c) const -> std::string;
|
[[nodiscard]] auto getShapeFilename(char c) const -> std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void GameScene::init() {
|
|||||||
score_per_player_[1] = 0;
|
score_per_player_[1] = 0;
|
||||||
floating_score_manager_.reset();
|
floating_score_manager_.reset();
|
||||||
|
|
||||||
// DEPRECATED: spawn_position_ ya no s'usa, es calcula dinàmicament con obtenir_punt_spawn(player_id)
|
// DEPRECATED: spawn_position_ ya no s'usa, es calcula dinàmicament con getSpawnPoint(player_id)
|
||||||
// const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
// const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||||
// spawn_position_.x = zona.x + zona.w * 0.5f;
|
// spawn_position_.x = zona.x + zona.w * 0.5f;
|
||||||
// spawn_position_.y = zona.y + zona.h * Defaults::Game::INIT_HUD_SHIP_START_Y_RATIO;
|
// spawn_position_.y = zona.y + zona.h * Defaults::Game::INIT_HUD_SHIP_START_Y_RATIO;
|
||||||
@@ -133,7 +133,7 @@ void GameScene::init() {
|
|||||||
|
|
||||||
if (jugador_actiu) {
|
if (jugador_actiu) {
|
||||||
// Jugador active: init normalment
|
// Jugador active: init normalment
|
||||||
Vec2 spawn_pos = obtenir_punt_spawn(i);
|
Vec2 spawn_pos = getSpawnPoint(i);
|
||||||
ships_[i].init(&spawn_pos, false); // No invulnerability at start
|
ships_[i].init(&spawn_pos, false); // No invulnerability at start
|
||||||
// Registrar el cuerpo físico de la nave en el mundo (Fase 6c)
|
// Registrar el cuerpo físico de la nave en el mundo (Fase 6c)
|
||||||
physics_world_.addBody(&ships_[i].getBody());
|
physics_world_.addBody(&ships_[i].getBody());
|
||||||
@@ -213,11 +213,11 @@ void GameScene::stepShootingInput() {
|
|||||||
auto* input = Input::get();
|
auto* input = Input::get();
|
||||||
if (match_config_.jugador1_actiu &&
|
if (match_config_.jugador1_actiu &&
|
||||||
input->checkActionPlayer1(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
input->checkActionPlayer1(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||||
disparar_bala(0);
|
fireBullet(0);
|
||||||
}
|
}
|
||||||
if (match_config_.jugador2_actiu &&
|
if (match_config_.jugador2_actiu &&
|
||||||
input->checkActionPlayer2(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
input->checkActionPlayer2(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||||
disparar_bala(1);
|
fireBullet(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ void GameScene::stepMidGameJoin() {
|
|||||||
? input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)
|
? input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)
|
||||||
: input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
: input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
||||||
if (START_PRESSED) {
|
if (START_PRESSED) {
|
||||||
unir_jugador(pid);
|
joinPlayer(pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ auto GameScene::stepContinueScreen(float delta_time) -> bool {
|
|||||||
.hit_timer_per_player = hit_timer_per_player_,
|
.hit_timer_per_player = hit_timer_per_player_,
|
||||||
.ships = ships_,
|
.ships = ships_,
|
||||||
.match_config = match_config_,
|
.match_config = match_config_,
|
||||||
.get_spawn_point = [this](uint8_t pid) { return obtenir_punt_spawn(pid); },
|
.get_spawn_point = [this](uint8_t pid) { return getSpawnPoint(pid); },
|
||||||
};
|
};
|
||||||
Systems::ContinueScreen::update(cont_ctx, delta_time);
|
Systems::ContinueScreen::update(cont_ctx, delta_time);
|
||||||
Systems::ContinueScreen::processInput(cont_ctx);
|
Systems::ContinueScreen::processInput(cont_ctx);
|
||||||
@@ -326,7 +326,7 @@ void GameScene::stepDeathSequence(float delta_time) {
|
|||||||
// *** PHASE 3: RESPAWN OR GAME OVER ***
|
// *** PHASE 3: RESPAWN OR GAME OVER ***
|
||||||
lives_per_player_[i]--;
|
lives_per_player_[i]--;
|
||||||
if (lives_per_player_[i] > 0) {
|
if (lives_per_player_[i] > 0) {
|
||||||
Vec2 spawn_pos = obtenir_punt_spawn(i);
|
Vec2 spawn_pos = getSpawnPoint(i);
|
||||||
ships_[i].init(&spawn_pos, /*activar_invulnerabilitat=*/true);
|
ships_[i].init(&spawn_pos, /*activar_invulnerabilitat=*/true);
|
||||||
hit_timer_per_player_[i] = 0.0F;
|
hit_timer_per_player_[i] = 0.0F;
|
||||||
continue;
|
continue;
|
||||||
@@ -399,10 +399,10 @@ void GameScene::runStageInitHud(float delta_time) {
|
|||||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||||
|
|
||||||
if (match_config_.jugador1_actiu && SHIP1_P < 1.0F) {
|
if (match_config_.jugador1_actiu && SHIP1_P < 1.0F) {
|
||||||
ships_[0].setCenter(Systems::InitHud::computeShipPosition(SHIP1_P, obtenir_punt_spawn(0)));
|
ships_[0].setCenter(Systems::InitHud::computeShipPosition(SHIP1_P, getSpawnPoint(0)));
|
||||||
}
|
}
|
||||||
if (match_config_.jugador2_actiu && SHIP2_P < 1.0F) {
|
if (match_config_.jugador2_actiu && SHIP2_P < 1.0F) {
|
||||||
ships_[1].setCenter(Systems::InitHud::computeShipPosition(SHIP2_P, obtenir_punt_spawn(1)));
|
ships_[1].setCenter(Systems::InitHud::computeShipPosition(SHIP2_P, getSpawnPoint(1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ void GameScene::draw() {
|
|||||||
// Handle CONTINUE screen
|
// Handle CONTINUE screen
|
||||||
if (game_over_state_ == GameOverState::CONTINUE) {
|
if (game_over_state_ == GameOverState::CONTINUE) {
|
||||||
// Draw game background elements first
|
// Draw game background elements first
|
||||||
dibuixar_marges();
|
drawMargins();
|
||||||
|
|
||||||
for (const auto& enemy : enemies_) {
|
for (const auto& enemy : enemies_) {
|
||||||
enemy.draw();
|
enemy.draw();
|
||||||
@@ -503,17 +503,17 @@ void GameScene::draw() {
|
|||||||
|
|
||||||
debris_manager_.draw();
|
debris_manager_.draw();
|
||||||
floating_score_manager_.draw();
|
floating_score_manager_.draw();
|
||||||
dibuixar_marcador();
|
drawScoreboard();
|
||||||
|
|
||||||
// Draw CONTINUE screen overlay
|
// Draw CONTINUE screen overlay
|
||||||
dibuixar_continue();
|
drawContinue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle final GAME OVER state
|
// Handle final GAME OVER state
|
||||||
if (game_over_state_ == GameOverState::GAME_OVER) {
|
if (game_over_state_ == GameOverState::GAME_OVER) {
|
||||||
// Game over: draw enemies, bullets, debris, and "GAME OVER" text
|
// Game over: draw enemies, bullets, debris, and "GAME OVER" text
|
||||||
dibuixar_marges();
|
drawMargins();
|
||||||
|
|
||||||
for (const auto& enemy : enemies_) {
|
for (const auto& enemy : enemies_) {
|
||||||
enemy.draw();
|
enemy.draw();
|
||||||
@@ -538,7 +538,7 @@ void GameScene::draw() {
|
|||||||
|
|
||||||
text_.renderCentered(GAME_OVER_TEXT, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
text_.renderCentered(GAME_OVER_TEXT, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||||
|
|
||||||
dibuixar_marcador();
|
drawScoreboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -601,7 +601,7 @@ void GameScene::draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case StageSystem::EstatStage::LEVEL_START:
|
case StageSystem::EstatStage::LEVEL_START:
|
||||||
dibuixar_marges();
|
drawMargins();
|
||||||
// [NEW] Draw both ships if active and alive
|
// [NEW] Draw both ships if active and alive
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||||
@@ -620,12 +620,12 @@ void GameScene::draw() {
|
|||||||
floating_score_manager_.draw();
|
floating_score_manager_.draw();
|
||||||
|
|
||||||
// [EXISTING] Draw intro message and score
|
// [EXISTING] Draw intro message and score
|
||||||
dibuixar_missatge_stage(stage_manager_->get_missatge_level_start());
|
drawStageMessage(stage_manager_->get_missatge_level_start());
|
||||||
dibuixar_marcador();
|
drawScoreboard();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StageSystem::EstatStage::PLAYING:
|
case StageSystem::EstatStage::PLAYING:
|
||||||
dibuixar_marges();
|
drawMargins();
|
||||||
|
|
||||||
// [EXISTING] Normal rendering - active ships
|
// [EXISTING] Normal rendering - active ships
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
@@ -645,11 +645,11 @@ void GameScene::draw() {
|
|||||||
|
|
||||||
debris_manager_.draw();
|
debris_manager_.draw();
|
||||||
floating_score_manager_.draw();
|
floating_score_manager_.draw();
|
||||||
dibuixar_marcador();
|
drawScoreboard();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StageSystem::EstatStage::LEVEL_COMPLETED:
|
case StageSystem::EstatStage::LEVEL_COMPLETED:
|
||||||
dibuixar_marges();
|
drawMargins();
|
||||||
// [NEW] Draw both ships if active and alive
|
// [NEW] Draw both ships if active and alive
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||||
@@ -668,8 +668,8 @@ void GameScene::draw() {
|
|||||||
floating_score_manager_.draw();
|
floating_score_manager_.draw();
|
||||||
|
|
||||||
// [EXISTING] Draw completion message and score
|
// [EXISTING] Draw completion message and score
|
||||||
dibuixar_missatge_stage(StageSystem::Constants::MISSATGE_LEVEL_COMPLETED);
|
drawStageMessage(StageSystem::Constants::MISSATGE_LEVEL_COMPLETED);
|
||||||
dibuixar_marcador();
|
drawScoreboard();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -714,7 +714,7 @@ void GameScene::tocado(uint8_t player_id) {
|
|||||||
// Phase 3 is handled in update() when hit_timer_per_player_ >= DEATH_DURATION
|
// Phase 3 is handled in update() when hit_timer_per_player_ >= DEATH_DURATION
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::dibuixar_marges() const {
|
void GameScene::drawMargins() const {
|
||||||
// Dibuixar rectangle de la zona de juego
|
// Dibuixar rectangle de la zona de juego
|
||||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||||
|
|
||||||
@@ -731,7 +731,7 @@ void GameScene::dibuixar_marges() const {
|
|||||||
Rendering::linea(sdl_.getRenderer(), x2, y1, x2, y2); // Right
|
Rendering::linea(sdl_.getRenderer(), x2, y1, x2, y2); // Right
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::dibuixar_marcador() {
|
void GameScene::drawScoreboard() {
|
||||||
// Construir text del marcador
|
// Construir text del marcador
|
||||||
std::string text = buildScoreboard();
|
std::string text = buildScoreboard();
|
||||||
|
|
||||||
@@ -789,7 +789,7 @@ auto GameScene::buildScoreboard() const -> std::string {
|
|||||||
|
|
||||||
// [NEW] Stage system helper methods
|
// [NEW] Stage system helper methods
|
||||||
|
|
||||||
void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
void GameScene::drawStageMessage(const std::string& message) {
|
||||||
constexpr float BASE_SCALE = 1.0F;
|
constexpr float BASE_SCALE = 1.0F;
|
||||||
constexpr float SPACING = 2.0F;
|
constexpr float SPACING = 2.0F;
|
||||||
|
|
||||||
@@ -858,7 +858,7 @@ void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
|||||||
// Helper methods for 2-player support
|
// Helper methods for 2-player support
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|
||||||
auto GameScene::obtenir_punt_spawn(uint8_t player_id) const -> Vec2 {
|
auto GameScene::getSpawnPoint(uint8_t player_id) const -> Vec2 {
|
||||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||||
|
|
||||||
float x_ratio;
|
float x_ratio;
|
||||||
@@ -877,7 +877,7 @@ auto GameScene::obtenir_punt_spawn(uint8_t player_id) const -> Vec2 {
|
|||||||
.y = zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
|
.y = zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::disparar_bala(uint8_t player_id) {
|
void GameScene::fireBullet(uint8_t player_id) {
|
||||||
// Verificar que el player está vivo
|
// Verificar que el player está vivo
|
||||||
if (hit_timer_per_player_[player_id] > 0.0F) {
|
if (hit_timer_per_player_[player_id] > 0.0F) {
|
||||||
return;
|
return;
|
||||||
@@ -908,7 +908,7 @@ void GameScene::disparar_bala(uint8_t player_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::dibuixar_continue() {
|
void GameScene::drawContinue() {
|
||||||
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
|
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
|
||||||
constexpr float SPACING = 4.0F;
|
constexpr float SPACING = 4.0F;
|
||||||
|
|
||||||
@@ -943,7 +943,7 @@ void GameScene::dibuixar_continue() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::unir_jugador(uint8_t player_id) {
|
void GameScene::joinPlayer(uint8_t player_id) {
|
||||||
// Activate player
|
// Activate player
|
||||||
if (player_id == 0) {
|
if (player_id == 0) {
|
||||||
match_config_.jugador1_actiu = true;
|
match_config_.jugador1_actiu = true;
|
||||||
@@ -957,7 +957,7 @@ void GameScene::unir_jugador(uint8_t player_id) {
|
|||||||
hit_timer_per_player_[player_id] = 0.0F;
|
hit_timer_per_player_[player_id] = 0.0F;
|
||||||
|
|
||||||
// Spawn with invulnerability
|
// Spawn with invulnerability
|
||||||
Vec2 spawn_pos = obtenir_punt_spawn(player_id);
|
Vec2 spawn_pos = getSpawnPoint(player_id);
|
||||||
ships_[player_id].init(&spawn_pos, true);
|
ships_[player_id].init(&spawn_pos, true);
|
||||||
|
|
||||||
// No visual message, just spawn (per user requirement)
|
// No visual message, just spawn (per user requirement)
|
||||||
|
|||||||
@@ -88,17 +88,17 @@ class GameScene final : public Scene {
|
|||||||
|
|
||||||
// Funciones privades
|
// Funciones privades
|
||||||
void tocado(uint8_t player_id);
|
void tocado(uint8_t player_id);
|
||||||
void dibuixar_marges() const; // Dibuixar vores de la zona de juego
|
void drawMargins() const; // Dibuixar vores de la zona de juego
|
||||||
void dibuixar_marcador(); // Dibuixar marcador de puntuación
|
void drawScoreboard(); // Dibuixar marcador de puntuación
|
||||||
void disparar_bala(uint8_t player_id); // Shoot bullet from player
|
void fireBullet(uint8_t player_id); // Shoot bullet from player
|
||||||
[[nodiscard]] auto obtenir_punt_spawn(uint8_t player_id) const -> Vec2; // Get spawn position for player
|
[[nodiscard]] auto getSpawnPoint(uint8_t player_id) const -> Vec2; // Get spawn position for player
|
||||||
|
|
||||||
// [NEW] Continue & Join system
|
// [NEW] Continue & Join system
|
||||||
void unir_jugador(uint8_t player_id); // Join inactive player mid-game
|
void joinPlayer(uint8_t player_id); // Join inactive player mid-game
|
||||||
void dibuixar_continue(); // Draw continue screen
|
void drawContinue(); // Draw continue screen
|
||||||
|
|
||||||
// [NEW] Stage system helpers
|
// [NEW] Stage system helpers
|
||||||
void dibuixar_missatge_stage(const std::string& message);
|
void drawStageMessage(const std::string& message);
|
||||||
|
|
||||||
// [NEW] Función helper del marcador
|
// [NEW] Función helper del marcador
|
||||||
[[nodiscard]] auto buildScoreboard() const -> std::string;
|
[[nodiscard]] auto buildScoreboard() const -> std::string;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ LogoScene::LogoScene(SDLManager& sdl, SceneContext& context)
|
|||||||
(void)option; // Suprimir warning
|
(void)option; // Suprimir warning
|
||||||
|
|
||||||
so_reproduit_.fill(false); // Inicialitzar seguiment de sons
|
so_reproduit_.fill(false); // Inicialitzar seguiment de sons
|
||||||
inicialitzar_lletres();
|
initLetters();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogoScene::~LogoScene() {
|
LogoScene::~LogoScene() {
|
||||||
@@ -75,7 +75,7 @@ void LogoScene::handleEvent(const SDL_Event& event) {
|
|||||||
(void)event;
|
(void)event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoScene::inicialitzar_lletres() {
|
void LogoScene::initLetters() {
|
||||||
using namespace Graphics;
|
using namespace Graphics;
|
||||||
|
|
||||||
// Llista de archivos .shp (A repetida para las dues A's)
|
// Llista de archivos .shp (A repetida para las dues A's)
|
||||||
@@ -154,7 +154,7 @@ void LogoScene::inicialitzar_lletres() {
|
|||||||
<< " lletres carregades, ancho total: " << ancho_total << " px\n";
|
<< " lletres carregades, ancho total: " << ancho_total << " px\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoScene::canviar_estat(AnimationState nou_estat) {
|
void LogoScene::changeState(AnimationState nou_estat) {
|
||||||
estat_actual_ = nou_estat;
|
estat_actual_ = nou_estat;
|
||||||
temps_estat_actual_ = 0.0F; // Reset time
|
temps_estat_actual_ = 0.0F; // Reset time
|
||||||
|
|
||||||
@@ -179,12 +179,12 @@ void LogoScene::canviar_estat(AnimationState nou_estat) {
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto LogoScene::totes_lletres_completes() const -> bool {
|
auto LogoScene::allLettersComplete() const -> bool {
|
||||||
// Cuando global_progress = 1.0, todas las lletres tenen letra_progress = 1.0
|
// Cuando global_progress = 1.0, todas las lletres tenen letra_progress = 1.0
|
||||||
return temps_estat_actual_ >= DURACIO_ZOOM;
|
return temps_estat_actual_ >= DURACIO_ZOOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogoScene::actualitzar_explosions(float delta_time) {
|
void LogoScene::updateExplosions(float delta_time) {
|
||||||
temps_des_ultima_explosio_ += delta_time;
|
temps_des_ultima_explosio_ += delta_time;
|
||||||
|
|
||||||
// Comprovar si es el moment de explode la següent lletra
|
// Comprovar si es el moment de explode la següent lletra
|
||||||
@@ -211,7 +211,7 @@ void LogoScene::actualitzar_explosions(float delta_time) {
|
|||||||
temps_des_ultima_explosio_ = 0.0F;
|
temps_des_ultima_explosio_ = 0.0F;
|
||||||
} else {
|
} else {
|
||||||
// Todas las lletres han explotat, transición a POST_EXPLOSION
|
// Todas las lletres han explotat, transición a POST_EXPLOSION
|
||||||
canviar_estat(AnimationState::POST_EXPLOSION);
|
changeState(AnimationState::POST_EXPLOSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ void LogoScene::update(float delta_time) {
|
|||||||
switch (estat_actual_) {
|
switch (estat_actual_) {
|
||||||
case AnimationState::PRE_ANIMATION:
|
case AnimationState::PRE_ANIMATION:
|
||||||
if (temps_estat_actual_ >= DURACIO_PRE) {
|
if (temps_estat_actual_ >= DURACIO_PRE) {
|
||||||
canviar_estat(AnimationState::ANIMATION);
|
changeState(AnimationState::ANIMATION);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -246,20 +246,20 @@ void LogoScene::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totes_lletres_completes()) {
|
if (allLettersComplete()) {
|
||||||
canviar_estat(AnimationState::POST_ANIMATION);
|
changeState(AnimationState::POST_ANIMATION);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case AnimationState::POST_ANIMATION:
|
case AnimationState::POST_ANIMATION:
|
||||||
if (temps_estat_actual_ >= DURACIO_POST_ANIMATION) {
|
if (temps_estat_actual_ >= DURACIO_POST_ANIMATION) {
|
||||||
canviar_estat(AnimationState::EXPLOSION);
|
changeState(AnimationState::EXPLOSION);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AnimationState::EXPLOSION:
|
case AnimationState::EXPLOSION:
|
||||||
actualitzar_explosions(delta_time);
|
updateExplosions(delta_time);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AnimationState::POST_EXPLOSION:
|
case AnimationState::POST_EXPLOSION:
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ class LogoScene final : public Scene {
|
|||||||
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 inicialitzar_lletres();
|
void initLetters();
|
||||||
void actualitzar_explosions(float delta_time);
|
void updateExplosions(float delta_time);
|
||||||
auto checkSkipButtonPressed() -> bool;
|
auto checkSkipButtonPressed() -> bool;
|
||||||
|
|
||||||
// Métodos de gestió de estats
|
// Métodos de gestió de estats
|
||||||
void canviar_estat(AnimationState nou_estat);
|
void changeState(AnimationState nou_estat);
|
||||||
[[nodiscard]] auto totes_lletres_completes() const -> bool;
|
[[nodiscard]] auto allLettersComplete() const -> bool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicialitzar lletres del título "ORNI ATTACK!"
|
// Inicialitzar lletres del título "ORNI ATTACK!"
|
||||||
inicialitzar_titol();
|
initTitle();
|
||||||
|
|
||||||
// Logo JAILGAMES pequeño sobre el copyright inferior.
|
// Logo JAILGAMES pequeño sobre el copyright inferior.
|
||||||
inicialitzarJailgames();
|
inicialitzarJailgames();
|
||||||
@@ -100,7 +100,7 @@ TitleScene::~TitleScene() {
|
|||||||
Audio::get()->stopMusic();
|
Audio::get()->stopMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleScene::inicialitzar_titol() {
|
void TitleScene::initTitle() {
|
||||||
using namespace Graphics;
|
using namespace Graphics;
|
||||||
|
|
||||||
// === LÍNIA 1: "ORNI" ===
|
// === LÍNIA 1: "ORNI" ===
|
||||||
@@ -425,7 +425,7 @@ void TitleScene::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualitzar animación del logo
|
// Actualitzar animación del logo
|
||||||
actualitzar_animacio_logo(delta_time);
|
updateLogoAnimation(delta_time);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ void TitleScene::update(float delta_time) {
|
|||||||
temps_acumulat_ += delta_time;
|
temps_acumulat_ += delta_time;
|
||||||
|
|
||||||
// Continuar animación orbital durante la transición
|
// Continuar animación orbital durante la transición
|
||||||
actualitzar_animacio_logo(delta_time);
|
updateLogoAnimation(delta_time);
|
||||||
|
|
||||||
// [NOU] Continuar comprovant si l'altre player quiere unir-se durante la transición ("late join")
|
// [NOU] Continuar comprovant si l'altre player quiere unir-se durante la transición ("late join")
|
||||||
{
|
{
|
||||||
@@ -542,7 +542,7 @@ void TitleScene::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleScene::actualitzar_animacio_logo(float delta_time) {
|
void TitleScene::updateLogoAnimation(float delta_time) {
|
||||||
// Solo calcular i aplicar offsets si l'animación está activa
|
// Solo calcular i aplicar offsets si l'animación está activa
|
||||||
if (animacio_activa_) {
|
if (animacio_activa_) {
|
||||||
// Acumular time escalat
|
// Acumular time escalat
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ class TitleScene final : public Scene {
|
|||||||
static constexpr float DURACIO_LERP = 2.0F; // 2s per arribar a amplitud completa
|
static constexpr float DURACIO_LERP = 2.0F; // 2s per arribar a amplitud completa
|
||||||
|
|
||||||
// Métodos privats
|
// Métodos privats
|
||||||
void actualitzar_animacio_logo(float delta_time); // Actualitza l'animación orbital del logo
|
void updateLogoAnimation(float delta_time); // Actualitza l'animación orbital del logo
|
||||||
auto checkSkipButtonPressed() -> bool;
|
auto checkSkipButtonPressed() -> bool;
|
||||||
auto checkStartGameButtonPressed() -> bool;
|
auto checkStartGameButtonPressed() -> bool;
|
||||||
void inicialitzar_titol(); // Carrega i posiciona las lletres del título
|
void initTitle(); // Carrega i posiciona las lletres del título
|
||||||
void inicialitzarJailgames(); // Carrega i posiciona el logo JAILGAMES pequeño
|
void inicialitzarJailgames(); // Carrega i posiciona el logo JAILGAMES pequeño
|
||||||
void dibuixarPeuTitol(float spacing) const; // Logo JAILGAMES + línia de copyright
|
void dibuixarPeuTitol(float spacing) const; // Logo JAILGAMES + línia de copyright
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void SpawnController::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
generar_spawn_events();
|
generateSpawnEvents();
|
||||||
|
|
||||||
std::cout << "[SpawnController] Stage " << static_cast<int>(config_->stage_id)
|
std::cout << "[SpawnController] Stage " << static_cast<int>(config_->stage_id)
|
||||||
<< ": generats " << spawn_queue_.size() << " spawn events" << '\n';
|
<< ": generats " << spawn_queue_.size() << " spawn events" << '\n';
|
||||||
@@ -63,7 +63,7 @@ void SpawnController::update(float delta_time, std::array<Enemy, 15>& orni_array
|
|||||||
// Find first inactive enemy
|
// Find first inactive enemy
|
||||||
for (auto& enemy : orni_array) {
|
for (auto& enemy : orni_array) {
|
||||||
if (!enemy.isActive()) {
|
if (!enemy.isActive()) {
|
||||||
spawn_enemic(enemy, event.type, ship_position_);
|
spawnEnemy(enemy, event.type, ship_position_);
|
||||||
event.spawnejat = true;
|
event.spawnejat = true;
|
||||||
index_spawn_actual_++;
|
index_spawn_actual_++;
|
||||||
break;
|
break;
|
||||||
@@ -113,7 +113,7 @@ auto SpawnController::get_enemics_spawnejats() const -> uint8_t {
|
|||||||
return static_cast<uint8_t>(index_spawn_actual_);
|
return static_cast<uint8_t>(index_spawn_actual_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnController::generar_spawn_events() {
|
void SpawnController::generateSpawnEvents() {
|
||||||
if (config_ == nullptr) {
|
if (config_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,13 +122,13 @@ void SpawnController::generar_spawn_events() {
|
|||||||
float spawn_time = config_->config_spawn.delay_inicial +
|
float spawn_time = config_->config_spawn.delay_inicial +
|
||||||
(i * config_->config_spawn.interval_spawn);
|
(i * config_->config_spawn.interval_spawn);
|
||||||
|
|
||||||
EnemyType type = seleccionar_tipus_aleatori();
|
EnemyType type = selectRandomType();
|
||||||
|
|
||||||
spawn_queue_.push_back({spawn_time, type, false});
|
spawn_queue_.push_back({spawn_time, type, false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SpawnController::seleccionar_tipus_aleatori() const -> EnemyType {
|
auto SpawnController::selectRandomType() const -> EnemyType {
|
||||||
if (config_ == nullptr) {
|
if (config_ == nullptr) {
|
||||||
return EnemyType::PENTAGON;
|
return EnemyType::PENTAGON;
|
||||||
}
|
}
|
||||||
@@ -145,15 +145,15 @@ auto SpawnController::seleccionar_tipus_aleatori() const -> EnemyType {
|
|||||||
return EnemyType::MOLINILLO;
|
return EnemyType::MOLINILLO;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnController::spawn_enemic(Enemy& enemy, EnemyType type, const Vec2* ship_pos) {
|
void SpawnController::spawnEnemy(Enemy& enemy, EnemyType type, const Vec2* ship_pos) {
|
||||||
// Initialize enemy (with safe spawn if ship_pos provided)
|
// Initialize enemy (with safe spawn if ship_pos provided)
|
||||||
enemy.init(type, ship_pos);
|
enemy.init(type, ship_pos);
|
||||||
|
|
||||||
// Apply difficulty multipliers
|
// Apply difficulty multipliers
|
||||||
aplicar_multiplicadors(enemy);
|
applyMultipliers(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnController::aplicar_multiplicadors(Enemy& enemy) const {
|
void SpawnController::applyMultipliers(Enemy& enemy) const {
|
||||||
if (config_ == nullptr) {
|
if (config_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ class SpawnController {
|
|||||||
uint8_t index_spawn_actual_{0}; // Next spawn to process
|
uint8_t index_spawn_actual_{0}; // Next spawn to process
|
||||||
|
|
||||||
// Spawn generation
|
// Spawn generation
|
||||||
void generar_spawn_events();
|
void generateSpawnEvents();
|
||||||
[[nodiscard]] auto seleccionar_tipus_aleatori() const -> EnemyType;
|
[[nodiscard]] auto selectRandomType() const -> EnemyType;
|
||||||
void spawn_enemic(Enemy& enemy, EnemyType type, const Vec2* ship_pos = nullptr);
|
void spawnEnemy(Enemy& enemy, EnemyType type, const Vec2* ship_pos = nullptr);
|
||||||
void aplicar_multiplicadors(Enemy& enemy) const;
|
void applyMultipliers(Enemy& enemy) const;
|
||||||
const Vec2* ship_position_{nullptr}; // [NEW] Non-owning pointer to ship position
|
const Vec2* ship_position_{nullptr}; // [NEW] Non-owning pointer to ship position
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ auto StageLoader::load(const std::string& path) -> std::unique_ptr<StageSystemCo
|
|||||||
std::cerr << "[StageLoader] Error: falta camp 'metadata'" << '\n';
|
std::cerr << "[StageLoader] Error: falta camp 'metadata'" << '\n';
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!parse_metadata(yaml["metadata"], config->metadata)) {
|
if (!parseMetadata(yaml["metadata"], config->metadata)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,14 +64,14 @@ auto StageLoader::load(const std::string& path) -> std::unique_ptr<StageSystemCo
|
|||||||
|
|
||||||
for (const auto& stage_yaml : yaml["stages"]) {
|
for (const auto& stage_yaml : yaml["stages"]) {
|
||||||
StageConfig stage;
|
StageConfig stage;
|
||||||
if (!parse_stage(stage_yaml, stage)) {
|
if (!parseStage(stage_yaml, stage)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
config->stages.push_back(stage);
|
config->stages.push_back(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validar configuración
|
// Validar configuración
|
||||||
if (!validar_config(*config)) {
|
if (!validateConfig(*config)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ auto StageLoader::load(const std::string& path) -> std::unique_ptr<StageSystemCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_metadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool {
|
auto StageLoader::parseMetadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("version") || !yaml.contains("total_stages")) {
|
if (!yaml.contains("version") || !yaml.contains("total_stages")) {
|
||||||
std::cerr << "[StageLoader] Error: metadata incompleta" << '\n';
|
std::cerr << "[StageLoader] Error: metadata incompleta" << '\n';
|
||||||
@@ -105,7 +105,7 @@ auto StageLoader::parse_metadata(const fkyaml::node& yaml, MetadataStages& meta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> bool {
|
auto StageLoader::parseStage(const fkyaml::node& yaml, StageConfig& stage) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("stage_id") || !yaml.contains("total_enemies") ||
|
if (!yaml.contains("stage_id") || !yaml.contains("total_enemies") ||
|
||||||
!yaml.contains("spawn_config") || !yaml.contains("enemy_distribution") ||
|
!yaml.contains("spawn_config") || !yaml.contains("enemy_distribution") ||
|
||||||
@@ -117,13 +117,13 @@ auto StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> b
|
|||||||
stage.stage_id = yaml["stage_id"].get_value<uint8_t>();
|
stage.stage_id = yaml["stage_id"].get_value<uint8_t>();
|
||||||
stage.total_enemies = yaml["total_enemies"].get_value<uint8_t>();
|
stage.total_enemies = yaml["total_enemies"].get_value<uint8_t>();
|
||||||
|
|
||||||
if (!parse_spawn_config(yaml["spawn_config"], stage.config_spawn)) {
|
if (!parseSpawnConfig(yaml["spawn_config"], stage.config_spawn)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!parse_distribution(yaml["enemy_distribution"], stage.distribucio)) {
|
if (!parseDistribution(yaml["enemy_distribution"], stage.distribucio)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!parse_multipliers(yaml["difficulty_multipliers"], stage.multiplicadors)) {
|
if (!parseMultipliers(yaml["difficulty_multipliers"], stage.multiplicadors)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ auto StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config) -> bool {
|
auto StageLoader::parseSpawnConfig(const fkyaml::node& yaml, ConfigSpawn& config) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("mode") || !yaml.contains("initial_delay") ||
|
if (!yaml.contains("mode") || !yaml.contains("initial_delay") ||
|
||||||
!yaml.contains("spawn_interval")) {
|
!yaml.contains("spawn_interval")) {
|
||||||
@@ -149,7 +149,7 @@ auto StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& conf
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto mode_str = yaml["mode"].get_value<std::string>();
|
auto mode_str = yaml["mode"].get_value<std::string>();
|
||||||
config.mode = parse_spawn_mode(mode_str);
|
config.mode = parseSpawnMode(mode_str);
|
||||||
config.delay_inicial = yaml["initial_delay"].get_value<float>();
|
config.delay_inicial = yaml["initial_delay"].get_value<float>();
|
||||||
config.interval_spawn = yaml["spawn_interval"].get_value<float>();
|
config.interval_spawn = yaml["spawn_interval"].get_value<float>();
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ auto StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& conf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool {
|
auto StageLoader::parseDistribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("pentagon") || !yaml.contains("cuadrado") ||
|
if (!yaml.contains("pentagon") || !yaml.contains("cuadrado") ||
|
||||||
!yaml.contains("molinillo")) {
|
!yaml.contains("molinillo")) {
|
||||||
@@ -186,7 +186,7 @@ auto StageLoader::parse_distribution(const fkyaml::node& yaml, DistribucioEnemic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool {
|
auto StageLoader::parseMultipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("speed_multiplier") || !yaml.contains("rotation_multiplier") ||
|
if (!yaml.contains("speed_multiplier") || !yaml.contains("rotation_multiplier") ||
|
||||||
!yaml.contains("tracking_strength")) {
|
!yaml.contains("tracking_strength")) {
|
||||||
@@ -216,7 +216,7 @@ auto StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDifi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::parse_spawn_mode(const std::string& mode_str) -> ModeSpawn {
|
auto StageLoader::parseSpawnMode(const std::string& mode_str) -> ModeSpawn {
|
||||||
if (mode_str == "progressive") {
|
if (mode_str == "progressive") {
|
||||||
return ModeSpawn::PROGRESSIVE;
|
return ModeSpawn::PROGRESSIVE;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ auto StageLoader::parse_spawn_mode(const std::string& mode_str) -> ModeSpawn {
|
|||||||
return ModeSpawn::PROGRESSIVE;
|
return ModeSpawn::PROGRESSIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageLoader::validar_config(const StageSystemConfig& config) -> bool {
|
auto StageLoader::validateConfig(const StageSystemConfig& config) -> bool {
|
||||||
if (config.stages.empty()) {
|
if (config.stages.empty()) {
|
||||||
std::cerr << "[StageLoader] Error: sin stage carregat" << '\n';
|
std::cerr << "[StageLoader] Error: sin stage carregat" << '\n';
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ class StageLoader {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Parsing helpers (implementats en .cpp)
|
// Parsing helpers (implementats en .cpp)
|
||||||
static auto parse_metadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool;
|
static auto parseMetadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool;
|
||||||
static auto parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> bool;
|
static auto parseStage(const fkyaml::node& yaml, StageConfig& stage) -> bool;
|
||||||
static auto parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config) -> bool;
|
static auto parseSpawnConfig(const fkyaml::node& yaml, ConfigSpawn& config) -> bool;
|
||||||
static auto parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool;
|
static auto parseDistribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool;
|
||||||
static auto parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool;
|
static auto parseMultipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool;
|
||||||
static auto parse_spawn_mode(const std::string& mode_str) -> ModeSpawn;
|
static auto parseSpawnMode(const std::string& mode_str) -> ModeSpawn;
|
||||||
|
|
||||||
// Validació
|
// Validació
|
||||||
static auto validar_config(const StageSystemConfig& config) -> bool;
|
static auto validateConfig(const StageSystemConfig& config) -> bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace StageSystem
|
} // namespace StageSystem
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ StageManager::StageManager(const StageSystemConfig* config)
|
|||||||
|
|
||||||
void StageManager::init() {
|
void StageManager::init() {
|
||||||
stage_actual_ = 1;
|
stage_actual_ = 1;
|
||||||
carregar_stage(stage_actual_);
|
loadStage(stage_actual_);
|
||||||
canviar_estat(EstatStage::INIT_HUD);
|
changeState(EstatStage::INIT_HUD);
|
||||||
|
|
||||||
std::cout << "[StageManager] Inicialitzat a stage " << static_cast<int>(stage_actual_)
|
std::cout << "[StageManager] Inicialitzat a stage " << static_cast<int>(stage_actual_)
|
||||||
<< '\n';
|
<< '\n';
|
||||||
@@ -34,19 +34,19 @@ void StageManager::init() {
|
|||||||
void StageManager::update(float delta_time, bool pause_spawn) {
|
void StageManager::update(float delta_time, bool pause_spawn) {
|
||||||
switch (estat_) {
|
switch (estat_) {
|
||||||
case EstatStage::INIT_HUD:
|
case EstatStage::INIT_HUD:
|
||||||
processar_init_hud(delta_time);
|
processInitHud(delta_time);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EstatStage::LEVEL_START:
|
case EstatStage::LEVEL_START:
|
||||||
processar_level_start(delta_time);
|
processLevelStart(delta_time);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EstatStage::PLAYING:
|
case EstatStage::PLAYING:
|
||||||
processar_playing(delta_time, pause_spawn);
|
processPlaying(delta_time, pause_spawn);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EstatStage::LEVEL_COMPLETED:
|
case EstatStage::LEVEL_COMPLETED:
|
||||||
processar_level_completed(delta_time);
|
processLevelCompleted(delta_time);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ void StageManager::update(float delta_time, bool pause_spawn) {
|
|||||||
void StageManager::stage_completat() {
|
void StageManager::stage_completat() {
|
||||||
std::cout << "[StageManager] Stage " << static_cast<int>(stage_actual_) << " completat!"
|
std::cout << "[StageManager] Stage " << static_cast<int>(stage_actual_) << " completat!"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
canviar_estat(EstatStage::LEVEL_COMPLETED);
|
changeState(EstatStage::LEVEL_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StageManager::tot_completat() const -> bool {
|
auto StageManager::tot_completat() const -> bool {
|
||||||
@@ -67,7 +67,7 @@ auto StageManager::get_config_actual() const -> const StageConfig* {
|
|||||||
return config_->obte_stage(stage_actual_);
|
return config_->obte_stage(stage_actual_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::canviar_estat(EstatStage nou_estat) {
|
void StageManager::changeState(EstatStage nou_estat) {
|
||||||
estat_ = nou_estat;
|
estat_ = nou_estat;
|
||||||
|
|
||||||
// Set timer based on state type
|
// Set timer based on state type
|
||||||
@@ -109,23 +109,23 @@ void StageManager::canviar_estat(EstatStage nou_estat) {
|
|||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::processar_init_hud(float delta_time) {
|
void StageManager::processInitHud(float delta_time) {
|
||||||
timer_transicio_ -= delta_time;
|
timer_transicio_ -= delta_time;
|
||||||
|
|
||||||
if (timer_transicio_ <= 0.0F) {
|
if (timer_transicio_ <= 0.0F) {
|
||||||
canviar_estat(EstatStage::LEVEL_START);
|
changeState(EstatStage::LEVEL_START);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::processar_level_start(float delta_time) {
|
void StageManager::processLevelStart(float delta_time) {
|
||||||
timer_transicio_ -= delta_time;
|
timer_transicio_ -= delta_time;
|
||||||
|
|
||||||
if (timer_transicio_ <= 0.0F) {
|
if (timer_transicio_ <= 0.0F) {
|
||||||
canviar_estat(EstatStage::PLAYING);
|
changeState(EstatStage::PLAYING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::processar_playing(float delta_time, bool pause_spawn) {
|
void StageManager::processPlaying(float delta_time, bool pause_spawn) {
|
||||||
// Update spawn controller (pauses when pause_spawn = true)
|
// Update spawn controller (pauses when pause_spawn = true)
|
||||||
// Note: The actual enemy array update happens in GameScene::update()
|
// Note: The actual enemy array update happens in GameScene::update()
|
||||||
// This is just for internal timekeeping
|
// This is just for internal timekeeping
|
||||||
@@ -133,7 +133,7 @@ void StageManager::processar_playing(float delta_time, bool pause_spawn) {
|
|||||||
(void)pause_spawn; // Passed to spawn_controller_.update() by GameScene
|
(void)pause_spawn; // Passed to spawn_controller_.update() by GameScene
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::processar_level_completed(float delta_time) {
|
void StageManager::processLevelCompleted(float delta_time) {
|
||||||
timer_transicio_ -= delta_time;
|
timer_transicio_ -= delta_time;
|
||||||
|
|
||||||
if (timer_transicio_ <= 0.0F) {
|
if (timer_transicio_ <= 0.0F) {
|
||||||
@@ -148,12 +148,12 @@ void StageManager::processar_level_completed(float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load next stage
|
// Load next stage
|
||||||
carregar_stage(stage_actual_);
|
loadStage(stage_actual_);
|
||||||
canviar_estat(EstatStage::LEVEL_START);
|
changeState(EstatStage::LEVEL_START);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StageManager::carregar_stage(uint8_t stage_id) {
|
void StageManager::loadStage(uint8_t stage_id) {
|
||||||
const StageConfig* stage_config = config_->obte_stage(stage_id);
|
const StageConfig* stage_config = config_->obte_stage(stage_id);
|
||||||
if (stage_config == nullptr) {
|
if (stage_config == nullptr) {
|
||||||
std::cerr << "[StageManager] Error: no es pot trobar stage " << static_cast<int>(stage_id)
|
std::cerr << "[StageManager] Error: no es pot trobar stage " << static_cast<int>(stage_id)
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ class StageManager {
|
|||||||
std::string missatge_level_start_actual_; // Missatge seleccionat per al level actual
|
std::string missatge_level_start_actual_; // Missatge seleccionat per al level actual
|
||||||
|
|
||||||
// State transitions
|
// State transitions
|
||||||
void canviar_estat(EstatStage nou_estat);
|
void changeState(EstatStage nou_estat);
|
||||||
void processar_init_hud(float delta_time);
|
void processInitHud(float delta_time);
|
||||||
void processar_level_start(float delta_time);
|
void processLevelStart(float delta_time);
|
||||||
void processar_playing(float delta_time, bool pause_spawn);
|
void processPlaying(float delta_time, bool pause_spawn);
|
||||||
void processar_level_completed(float delta_time);
|
void processLevelCompleted(float delta_time);
|
||||||
void carregar_stage(uint8_t stage_id);
|
void loadStage(uint8_t stage_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace StageSystem
|
} // namespace StageSystem
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ void ShipAnimator::init() {
|
|||||||
// Configurar ship P1
|
// Configurar ship P1
|
||||||
ships_[0].player_id = 1;
|
ships_[0].player_id = 1;
|
||||||
ships_[0].shape = forma_p1;
|
ships_[0].shape = forma_p1;
|
||||||
configurar_nau_p1(ships_[0]);
|
configureShipP1(ships_[0]);
|
||||||
|
|
||||||
// Configurar ship P2
|
// Configurar ship P2
|
||||||
ships_[1].player_id = 2;
|
ships_[1].player_id = 2;
|
||||||
ships_[1].shape = forma_p2;
|
ships_[1].shape = forma_p2;
|
||||||
configurar_nau_p2(ships_[1]);
|
configureShipP2(ships_[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShipAnimator::update(float delta_time) {
|
void ShipAnimator::update(float delta_time) {
|
||||||
@@ -42,13 +42,13 @@ void ShipAnimator::update(float delta_time) {
|
|||||||
|
|
||||||
switch (ship.state) {
|
switch (ship.state) {
|
||||||
case ShipState::ENTERING:
|
case ShipState::ENTERING:
|
||||||
actualitzar_entering(ship, delta_time);
|
updateEntering(ship, delta_time);
|
||||||
break;
|
break;
|
||||||
case ShipState::FLOATING:
|
case ShipState::FLOATING:
|
||||||
actualitzar_floating(ship, delta_time);
|
updateFloating(ship, delta_time);
|
||||||
break;
|
break;
|
||||||
case ShipState::EXITING:
|
case ShipState::EXITING:
|
||||||
actualitzar_exiting(ship, delta_time);
|
updateExiting(ship, delta_time);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,14 +79,14 @@ void ShipAnimator::start_entry_animation() {
|
|||||||
// Configurar ship P1 para l'animación de entrada
|
// Configurar ship P1 para l'animación de entrada
|
||||||
ships_[0].state = ShipState::ENTERING;
|
ships_[0].state = ShipState::ENTERING;
|
||||||
ships_[0].state_time = 0.0F;
|
ships_[0].state_time = 0.0F;
|
||||||
ships_[0].initial_position = calcular_posicio_fora_pantalla(CLOCK_8_ANGLE);
|
ships_[0].initial_position = computeOffscreenPosition(CLOCK_8_ANGLE);
|
||||||
ships_[0].current_position = ships_[0].initial_position;
|
ships_[0].current_position = ships_[0].initial_position;
|
||||||
ships_[0].current_scale = ships_[0].initial_scale;
|
ships_[0].current_scale = ships_[0].initial_scale;
|
||||||
|
|
||||||
// Configurar ship P2 para l'animación de entrada
|
// Configurar ship P2 para l'animación de entrada
|
||||||
ships_[1].state = ShipState::ENTERING;
|
ships_[1].state = ShipState::ENTERING;
|
||||||
ships_[1].state_time = 0.0F;
|
ships_[1].state_time = 0.0F;
|
||||||
ships_[1].initial_position = calcular_posicio_fora_pantalla(CLOCK_4_ANGLE);
|
ships_[1].initial_position = computeOffscreenPosition(CLOCK_4_ANGLE);
|
||||||
ships_[1].current_position = ships_[1].initial_position;
|
ships_[1].current_position = ships_[1].initial_position;
|
||||||
ships_[1].current_scale = ships_[1].initial_scale;
|
ships_[1].current_scale = ships_[1].initial_scale;
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ auto ShipAnimator::is_animation_complete() const -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Métodos de animación (stubs)
|
// Métodos de animación (stubs)
|
||||||
void ShipAnimator::actualitzar_entering(TitleShip& ship, float delta_time) {
|
void ShipAnimator::updateEntering(TitleShip& ship, float delta_time) {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
ship.state_time += delta_time;
|
ship.state_time += delta_time;
|
||||||
@@ -202,7 +202,7 @@ void ShipAnimator::actualitzar_entering(TitleShip& ship, float delta_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShipAnimator::actualitzar_floating(TitleShip& ship, float delta_time) {
|
void ShipAnimator::updateFloating(TitleShip& ship, float delta_time) {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
// Actualitzar time i fase de oscil·lació
|
// Actualitzar time i fase de oscil·lació
|
||||||
@@ -221,7 +221,7 @@ void ShipAnimator::actualitzar_floating(TitleShip& ship, float delta_time) {
|
|||||||
ship.current_scale = ship.target_scale;
|
ship.current_scale = ship.target_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShipAnimator::actualitzar_exiting(TitleShip& ship, float delta_time) {
|
void ShipAnimator::updateExiting(TitleShip& ship, float delta_time) {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
ship.state_time += delta_time;
|
ship.state_time += delta_time;
|
||||||
@@ -250,7 +250,7 @@ void ShipAnimator::actualitzar_exiting(TitleShip& ship, float delta_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configuración
|
// Configuración
|
||||||
void ShipAnimator::configurar_nau_p1(TitleShip& ship) {
|
void ShipAnimator::configureShipP1(TitleShip& ship) {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
// Estat inicial: FLOATING (per test estàtic)
|
// Estat inicial: FLOATING (per test estàtic)
|
||||||
@@ -261,7 +261,7 @@ void ShipAnimator::configurar_nau_p1(TitleShip& ship) {
|
|||||||
ship.target_position = {.x = P1_TARGET_X(), .y = P1_TARGET_Y()};
|
ship.target_position = {.x = P1_TARGET_X(), .y = P1_TARGET_Y()};
|
||||||
|
|
||||||
// Calcular posición inicial (fuera de pantalla)
|
// Calcular posición inicial (fuera de pantalla)
|
||||||
ship.initial_position = calcular_posicio_fora_pantalla(CLOCK_8_ANGLE);
|
ship.initial_position = computeOffscreenPosition(CLOCK_8_ANGLE);
|
||||||
ship.current_position = ship.initial_position; // Començar fuera de pantalla
|
ship.current_position = ship.initial_position; // Començar fuera de pantalla
|
||||||
|
|
||||||
// Escales
|
// Escales
|
||||||
@@ -285,7 +285,7 @@ void ShipAnimator::configurar_nau_p1(TitleShip& ship) {
|
|||||||
ship.visible = true;
|
ship.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShipAnimator::configurar_nau_p2(TitleShip& ship) {
|
void ShipAnimator::configureShipP2(TitleShip& ship) {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
// Estat inicial: FLOATING (per test estàtic)
|
// Estat inicial: FLOATING (per test estàtic)
|
||||||
@@ -296,7 +296,7 @@ void ShipAnimator::configurar_nau_p2(TitleShip& ship) {
|
|||||||
ship.target_position = {.x = P2_TARGET_X(), .y = P2_TARGET_Y()};
|
ship.target_position = {.x = P2_TARGET_X(), .y = P2_TARGET_Y()};
|
||||||
|
|
||||||
// Calcular posición inicial (fuera de pantalla)
|
// Calcular posición inicial (fuera de pantalla)
|
||||||
ship.initial_position = calcular_posicio_fora_pantalla(CLOCK_4_ANGLE);
|
ship.initial_position = computeOffscreenPosition(CLOCK_4_ANGLE);
|
||||||
ship.current_position = ship.initial_position; // Començar fuera de pantalla
|
ship.current_position = ship.initial_position; // Començar fuera de pantalla
|
||||||
|
|
||||||
// Escales
|
// Escales
|
||||||
@@ -320,7 +320,7 @@ void ShipAnimator::configurar_nau_p2(TitleShip& ship) {
|
|||||||
ship.visible = true;
|
ship.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ShipAnimator::calcular_posicio_fora_pantalla(float angle_rellotge) const -> Vec2 {
|
auto ShipAnimator::computeOffscreenPosition(float angle_rellotge) const -> Vec2 {
|
||||||
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)
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ class ShipAnimator {
|
|||||||
std::array<TitleShip, 2> ships_; // Naves P1 i P2
|
std::array<TitleShip, 2> ships_; // Naves P1 i P2
|
||||||
|
|
||||||
// Métodos de animación
|
// Métodos de animación
|
||||||
void actualitzar_entering(TitleShip& ship, float delta_time);
|
void updateEntering(TitleShip& ship, float delta_time);
|
||||||
void actualitzar_floating(TitleShip& ship, float delta_time);
|
void updateFloating(TitleShip& ship, float delta_time);
|
||||||
void actualitzar_exiting(TitleShip& ship, float delta_time);
|
void updateExiting(TitleShip& ship, float delta_time);
|
||||||
|
|
||||||
// Configuración
|
// Configuración
|
||||||
void configurar_nau_p1(TitleShip& ship);
|
void configureShipP1(TitleShip& ship);
|
||||||
void configurar_nau_p2(TitleShip& ship);
|
void configureShipP2(TitleShip& ship);
|
||||||
[[nodiscard]] auto calcular_posicio_fora_pantalla(float angle_rellotge) const -> Vec2;
|
[[nodiscard]] auto computeOffscreenPosition(float angle_rellotge) const -> Vec2;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Title
|
} // namespace Title
|
||||||
|
|||||||
Reference in New Issue
Block a user