Lint: rename públicos al inglés + refactor cognitive-complexity + unused-includes
Identifier-naming: rename de métodos públicos y cross-file al inglés
(camelBack), traducción de campos y locales en el proceso (TitleShip,
StageManager, SpawnController, ShipAnimator, helpers de PlayArea, etc.).
Refactor por cognitive-complexity (>25): GameScene::draw (59→3) con 9
helpers de estado, PhysicsWorld::resolveBodyCollisions (35→5) extrayendo
resolveBodyPair, Options::load{Window,Physics,Audio}ConfigFromYaml
(32/49/57→5/2/3) con templates readField, TitleScene::update (68→4) con
5 sub-pasos por estado + handleSkipInput/handleStartInput +
triggerExitForJoinedPlayers, DebrisManager::explode (39→3) con
extractSegments/spawnDebris/applyAngularVelocity/applyVisualRotation.
use-anyofallof: bucles → std::ranges::any_of/all_of en Input,
ShipAnimator y SpawnController.
readability-static-accessed-through-instance: Director::run y
VectorText::getTextWidth/Height invocados por clase.
readability-convert-member-functions-to-static: ResourcePack::decryptData.
unused-includes: eliminación de <utility>, <cstdint>, <vector>,
<iostream>, defaults.hpp y otros no usados directamente en headers y
unidades de traducción. Restablecido core/defaults.hpp en title_scene.cpp
(falsa "unused" del header).
Bug fix: eliminado isActive() duplicado en Bullet (redeclaración tras
rename de esta_activa→isActive que chocaba con el override de Entity).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4e5ab6be1d
commit
bbbb8d47ae
53 files changed
+818
-894
No files matched your search
+149
-186
@@ -8,13 +8,9 @@
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/entities/entity.hpp"
|
||||
#include "core/input/input.hpp"
|
||||
#include "core/math/easing.hpp"
|
||||
#include "core/physics/collision.hpp"
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
#include "core/system/scene_context.hpp"
|
||||
#include "game/stage_system/stage_loader.hpp"
|
||||
@@ -223,7 +219,7 @@ void GameScene::stepShootingInput() {
|
||||
|
||||
void GameScene::stepMidGameJoin() {
|
||||
// Permitir join solo durante PLAYING.
|
||||
if (stage_manager_->get_estat() != StageSystem::EstatStage::PLAYING) {
|
||||
if (stage_manager_->getState() != StageSystem::EstatStage::PLAYING) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,7 +357,7 @@ void GameScene::stepDeathSequence(float delta_time) {
|
||||
}
|
||||
|
||||
void GameScene::stepStageStateMachine(float delta_time) {
|
||||
const StageSystem::EstatStage STATE = stage_manager_->get_estat();
|
||||
const StageSystem::EstatStage STATE = stage_manager_->getState();
|
||||
switch (STATE) {
|
||||
case StageSystem::EstatStage::INIT_HUD:
|
||||
runStageInitHud(delta_time);
|
||||
@@ -382,11 +378,11 @@ void GameScene::runStageInitHud(float delta_time) {
|
||||
// Update stage manager timer (puede cambiar el state).
|
||||
stage_manager_->update(delta_time);
|
||||
// Si el state cambió, salir para no usar el timer del nuevo state.
|
||||
if (stage_manager_->get_estat() != StageSystem::EstatStage::INIT_HUD) {
|
||||
if (stage_manager_->getState() != StageSystem::EstatStage::INIT_HUD) {
|
||||
return;
|
||||
}
|
||||
|
||||
float global_progress = 1.0F - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION);
|
||||
float global_progress = 1.0F - (stage_manager_->getTransitionTimer() / Defaults::Game::INIT_HUD_DURATION);
|
||||
global_progress = std::min(1.0F, global_progress);
|
||||
|
||||
const float SHIP1_P = Systems::InitHud::computeRangeProgress(
|
||||
@@ -429,8 +425,8 @@ void GameScene::runStagePlaying(float delta_time) {
|
||||
|
||||
// Stage completado: cuando al menos un jugador está vivo y todos los enemies muertos.
|
||||
const bool ALGU_VIU = (hit_timer_per_player_[0] == 0.0F || hit_timer_per_player_[1] == 0.0F);
|
||||
if (ALGU_VIU && stage_manager_->getSpawnController().tots_enemics_destruits(enemies_)) {
|
||||
stage_manager_->stage_completat();
|
||||
if (ALGU_VIU && stage_manager_->getSpawnController().allEnemiesDestroyed(enemies_)) {
|
||||
stage_manager_->markStageCompleted();
|
||||
Audio::get()->playSound(Defaults::Sound::GOOD_JOB_COMMANDER, Audio::Group::GAME);
|
||||
return;
|
||||
}
|
||||
@@ -488,192 +484,159 @@ void GameScene::runCollisionDetections() {
|
||||
}
|
||||
|
||||
void GameScene::draw() {
|
||||
// Handle CONTINUE screen
|
||||
if (game_over_state_ == GameOverState::CONTINUE) {
|
||||
// Draw game background elements first
|
||||
drawMargins();
|
||||
|
||||
for (const auto& enemy : enemies_) {
|
||||
enemy.draw();
|
||||
}
|
||||
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawScoreboard();
|
||||
|
||||
// Draw CONTINUE screen overlay
|
||||
drawContinue();
|
||||
drawContinueState();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle final GAME OVER state
|
||||
if (game_over_state_ == GameOverState::GAME_OVER) {
|
||||
// Game over: draw enemies, bullets, debris, and "GAME OVER" text
|
||||
drawMargins();
|
||||
|
||||
for (const auto& enemy : enemies_) {
|
||||
enemy.draw();
|
||||
}
|
||||
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
|
||||
// Draw centered "GAME OVER" text
|
||||
const std::string GAME_OVER_TEXT = "GAME OVER";
|
||||
constexpr float SCALE = Defaults::Game::GameOverScreen::TEXT_SCALE;
|
||||
constexpr float SPACING = Defaults::Game::GameOverScreen::TEXT_SPACING;
|
||||
|
||||
// Calcular centro de l'àrea de juego usant constants
|
||||
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
|
||||
float centre_x = play_area.x + (play_area.w / 2.0F);
|
||||
float centre_y = play_area.y + (play_area.h / 2.0F);
|
||||
|
||||
text_.renderCentered(GAME_OVER_TEXT, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||
|
||||
drawScoreboard();
|
||||
drawGameOverState();
|
||||
return;
|
||||
}
|
||||
|
||||
// [NEW] Stage state rendering
|
||||
StageSystem::EstatStage state = stage_manager_->get_estat();
|
||||
|
||||
switch (state) {
|
||||
case StageSystem::EstatStage::INIT_HUD: {
|
||||
// Calcular progrés de cada animación independent
|
||||
float timer = stage_manager_->get_timer_transicio();
|
||||
float total_time = Defaults::Game::INIT_HUD_DURATION;
|
||||
float global_progress = 1.0F - (timer / total_time);
|
||||
|
||||
// [NEW] Calcular progress independiente para cada elemento
|
||||
float rect_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_RECT_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_RECT_RATIO_END);
|
||||
|
||||
float score_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SCORE_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SCORE_RATIO_END);
|
||||
|
||||
float ship1_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_END);
|
||||
|
||||
float ship2_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||
|
||||
// Dibuixar elements animats
|
||||
if (rect_progress > 0.0F) {
|
||||
// [NOU] Reproduir so cuando comença l'animación del rectangle
|
||||
if (!init_hud_rect_sound_played_) {
|
||||
Audio::get()->playSound(Defaults::Sound::INIT_HUD, Audio::Group::GAME);
|
||||
init_hud_rect_sound_played_ = true;
|
||||
}
|
||||
|
||||
Systems::InitHud::drawBordersAnimated(sdl_.getRenderer(), rect_progress);
|
||||
}
|
||||
|
||||
if (score_progress > 0.0F) {
|
||||
Systems::InitHud::drawScoreboardAnimated(text_, buildScoreboard(), score_progress);
|
||||
}
|
||||
|
||||
// [MODIFICAT] Dibuixar naves con progress independent
|
||||
if (ship1_progress > 0.0F && match_config_.jugador1_actiu && !ships_[0].isHit()) {
|
||||
ships_[0].draw();
|
||||
}
|
||||
|
||||
if (ship2_progress > 0.0F && match_config_.jugador2_actiu && !ships_[1].isHit()) {
|
||||
ships_[1].draw();
|
||||
}
|
||||
|
||||
switch (stage_manager_->getState()) {
|
||||
case StageSystem::EstatStage::INIT_HUD:
|
||||
drawInitHudState();
|
||||
break;
|
||||
}
|
||||
|
||||
case StageSystem::EstatStage::LEVEL_START:
|
||||
drawMargins();
|
||||
// [NEW] Draw both ships if active and alive
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
if (jugador_actiu && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
// [NEW] Draw bullets
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
|
||||
// [NEW] Draw debris
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
|
||||
// [EXISTING] Draw intro message and score
|
||||
drawStageMessage(stage_manager_->get_missatge_level_start());
|
||||
drawScoreboard();
|
||||
drawLevelStartState();
|
||||
break;
|
||||
|
||||
case StageSystem::EstatStage::PLAYING:
|
||||
drawMargins();
|
||||
|
||||
// [EXISTING] Normal rendering - active ships
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
if (jugador_actiu && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& enemy : enemies_) {
|
||||
enemy.draw();
|
||||
}
|
||||
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawScoreboard();
|
||||
drawPlayingState();
|
||||
break;
|
||||
|
||||
case StageSystem::EstatStage::LEVEL_COMPLETED:
|
||||
drawMargins();
|
||||
// [NEW] Draw both ships if active and alive
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
if (jugador_actiu && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
// [NEW] Draw bullets (allow last shots to be visible)
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
|
||||
// [NEW] Draw debris (from last destroyed enemies)
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
|
||||
// [EXISTING] Draw completion message and score
|
||||
drawStageMessage(StageSystem::Constants::MISSATGE_LEVEL_COMPLETED);
|
||||
drawScoreboard();
|
||||
drawLevelCompletedState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::drawEnemies() const {
|
||||
for (const auto& enemy : enemies_) {
|
||||
enemy.draw();
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::drawBullets() const {
|
||||
for (const auto& bullet : bullets_) {
|
||||
bullet.draw();
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::drawActiveShipsAlive() const {
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
if (jugador_actiu && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::drawContinueState() {
|
||||
drawMargins();
|
||||
drawEnemies();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawScoreboard();
|
||||
drawContinue();
|
||||
}
|
||||
|
||||
void GameScene::drawGameOverState() {
|
||||
drawMargins();
|
||||
drawEnemies();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
|
||||
const std::string GAME_OVER_TEXT = "GAME OVER";
|
||||
constexpr float SCALE = Defaults::Game::GameOverScreen::TEXT_SCALE;
|
||||
constexpr float SPACING = Defaults::Game::GameOverScreen::TEXT_SPACING;
|
||||
|
||||
const SDL_FRect& play_area = Defaults::Zones::PLAYAREA;
|
||||
float centre_x = play_area.x + (play_area.w / 2.0F);
|
||||
float centre_y = play_area.y + (play_area.h / 2.0F);
|
||||
|
||||
text_.renderCentered(GAME_OVER_TEXT, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||
|
||||
drawScoreboard();
|
||||
}
|
||||
|
||||
void GameScene::drawInitHudState() {
|
||||
float timer = stage_manager_->getTransitionTimer();
|
||||
float total_time = Defaults::Game::INIT_HUD_DURATION;
|
||||
float global_progress = 1.0F - (timer / total_time);
|
||||
|
||||
float rect_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_RECT_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_RECT_RATIO_END);
|
||||
|
||||
float score_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SCORE_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SCORE_RATIO_END);
|
||||
|
||||
float ship1_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SHIP1_RATIO_END);
|
||||
|
||||
float ship2_progress = Systems::InitHud::computeRangeProgress(
|
||||
global_progress,
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||
|
||||
if (rect_progress > 0.0F) {
|
||||
if (!init_hud_rect_sound_played_) {
|
||||
Audio::get()->playSound(Defaults::Sound::INIT_HUD, Audio::Group::GAME);
|
||||
init_hud_rect_sound_played_ = true;
|
||||
}
|
||||
Systems::InitHud::drawBordersAnimated(sdl_.getRenderer(), rect_progress);
|
||||
}
|
||||
|
||||
if (score_progress > 0.0F) {
|
||||
Systems::InitHud::drawScoreboardAnimated(text_, buildScoreboard(), score_progress);
|
||||
}
|
||||
|
||||
if (ship1_progress > 0.0F && match_config_.jugador1_actiu && !ships_[0].isHit()) {
|
||||
ships_[0].draw();
|
||||
}
|
||||
|
||||
if (ship2_progress > 0.0F && match_config_.jugador2_actiu && !ships_[1].isHit()) {
|
||||
ships_[1].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::drawLevelStartState() {
|
||||
drawMargins();
|
||||
drawActiveShipsAlive();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawStageMessage(stage_manager_->getLevelStartMessage());
|
||||
drawScoreboard();
|
||||
}
|
||||
|
||||
void GameScene::drawPlayingState() {
|
||||
drawMargins();
|
||||
drawActiveShipsAlive();
|
||||
drawEnemies();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawScoreboard();
|
||||
}
|
||||
|
||||
void GameScene::drawLevelCompletedState() {
|
||||
drawMargins();
|
||||
drawActiveShipsAlive();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
floating_score_manager_.draw();
|
||||
drawStageMessage(StageSystem::Constants::MISSATGE_LEVEL_COMPLETED);
|
||||
drawScoreboard();
|
||||
}
|
||||
|
||||
void GameScene::tocado(uint8_t player_id) {
|
||||
// Death sequence: 3 phases
|
||||
// Phase 1: First call (hit_timer_per_player_[player_id] == 0) - trigger explosion
|
||||
@@ -764,7 +727,7 @@ auto GameScene::buildScoreboard() const -> std::string {
|
||||
}
|
||||
|
||||
// Nivel (2 dígits)
|
||||
uint8_t stage_num = stage_manager_->get_stage_actual();
|
||||
uint8_t stage_num = stage_manager_->getCurrentStage();
|
||||
std::string stage_str = (stage_num < 10) ? "0" + std::to_string(stage_num)
|
||||
: std::to_string(stage_num);
|
||||
|
||||
@@ -801,7 +764,7 @@ void GameScene::drawStageMessage(const std::string& message) {
|
||||
float total_time;
|
||||
float typing_ratio;
|
||||
|
||||
if (stage_manager_->get_estat() == StageSystem::EstatStage::LEVEL_START) {
|
||||
if (stage_manager_->getState() == StageSystem::EstatStage::LEVEL_START) {
|
||||
total_time = Defaults::Game::LEVEL_START_DURATION;
|
||||
typing_ratio = Defaults::Game::LEVEL_START_TYPING_RATIO;
|
||||
} else { // LEVEL_COMPLETED
|
||||
@@ -810,7 +773,7 @@ void GameScene::drawStageMessage(const std::string& message) {
|
||||
}
|
||||
|
||||
// Calculate progress from timer (0.0 at start → 1.0 at end)
|
||||
float remaining_time = stage_manager_->get_timer_transicio();
|
||||
float remaining_time = stage_manager_->getTransitionTimer();
|
||||
float progress = 1.0F - (remaining_time / total_time);
|
||||
|
||||
// Determine how many characters to show
|
||||
@@ -834,7 +797,7 @@ void GameScene::drawStageMessage(const std::string& message) {
|
||||
// ===================================================
|
||||
|
||||
// Calculate text width at base scale (using FULL message for position calculation)
|
||||
float text_width_at_base = text_.get_text_width(message, BASE_SCALE, SPACING);
|
||||
float text_width_at_base = Graphics::VectorText::getTextWidth(message, BASE_SCALE, SPACING);
|
||||
|
||||
// Auto-scale if text exceeds max width
|
||||
float scale = (text_width_at_base <= MAX_WIDTH)
|
||||
@@ -842,8 +805,8 @@ void GameScene::drawStageMessage(const std::string& message) {
|
||||
: MAX_WIDTH / text_width_at_base;
|
||||
|
||||
// Recalculate dimensions with final scale (using FULL message for centering)
|
||||
float full_text_width = text_.get_text_width(message, scale, SPACING);
|
||||
float text_height = text_.get_text_height(scale);
|
||||
float full_text_width = Graphics::VectorText::getTextWidth(message, scale, SPACING);
|
||||
float text_height = Graphics::VectorText::getTextHeight(scale);
|
||||
|
||||
// Calculate position as if FULL text was there (for fixed position typewriter)
|
||||
float x = play_area.x + ((play_area.w - full_text_width) / 2.0F);
|
||||
@@ -862,7 +825,7 @@ auto GameScene::getSpawnPoint(uint8_t player_id) const -> Vec2 {
|
||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||
|
||||
float x_ratio;
|
||||
if (match_config_.es_un_jugador()) {
|
||||
if (match_config_.isSinglePlayer()) {
|
||||
// Un sol player: spawn al centro (50%)
|
||||
x_ratio = 0.5F;
|
||||
} else {
|
||||
@@ -901,7 +864,7 @@ void GameScene::fireBullet(uint8_t player_id) {
|
||||
// Buscar primera bullet inactiva en el pool del player
|
||||
int start_idx = player_id * 3; // P1=[0,1,2], P2=[3,4,5]
|
||||
for (int i = start_idx; i < start_idx + 3; i++) {
|
||||
if (!bullets_[i].esta_activa()) {
|
||||
if (!bullets_[i].isActive()) {
|
||||
bullets_[i].disparar(posicio_dispar, ship_angle, player_id);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,18 @@ class GameScene final : public Scene {
|
||||
// [NEW] Stage system helpers
|
||||
void drawStageMessage(const std::string& message);
|
||||
|
||||
// Helpers de renderitzat (extracció de draw() per reduir complexitat).
|
||||
// Cadascun gestiona un bloc concret; draw() només despatxa segons l'estat.
|
||||
void drawEnemies() const;
|
||||
void drawBullets() const;
|
||||
void drawActiveShipsAlive() const;
|
||||
void drawContinueState();
|
||||
void drawGameOverState();
|
||||
void drawInitHudState();
|
||||
void drawLevelStartState();
|
||||
void drawPlayingState();
|
||||
void drawLevelCompletedState();
|
||||
|
||||
// [NEW] Función helper del marcador
|
||||
[[nodiscard]] auto buildScoreboard() const -> std::string;
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void LogoScene::initLetters() {
|
||||
float min_x = FLT_MAX;
|
||||
float max_x = -FLT_MAX;
|
||||
|
||||
for (const auto& prim : shape->get_primitives()) {
|
||||
for (const auto& prim : shape->getPrimitives()) {
|
||||
for (const auto& point : prim.points) {
|
||||
min_x = std::min(min_x, point.x);
|
||||
max_x = std::max(max_x, point.x);
|
||||
@@ -321,7 +321,7 @@ void LogoScene::draw() {
|
||||
float current_scale =
|
||||
ESCALA_INICIAL + ((ESCALA_FINAL - ESCALA_INICIAL) * ease_factor);
|
||||
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletra.shape,
|
||||
pos_actual,
|
||||
@@ -344,7 +344,7 @@ void LogoScene::draw() {
|
||||
if (!explotades.contains(i)) {
|
||||
const auto& lletra = lletres_[i];
|
||||
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletra.shape,
|
||||
lletra.position,
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/graphics/shape.hpp"
|
||||
#include "core/input/input_types.hpp"
|
||||
#include "core/rendering/sdl_manager.hpp"
|
||||
#include "core/system/scene.hpp"
|
||||
#include "core/system/scene_context.hpp"
|
||||
|
||||
+189
-168
@@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/graphics/shape_loader.hpp"
|
||||
#include "core/input/input.hpp"
|
||||
#include "core/rendering/shape_renderer.hpp"
|
||||
@@ -64,10 +65,10 @@ TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
||||
// Brightness depèn de l'opción
|
||||
if (estat_actual_ == TitleState::MAIN) {
|
||||
// Si saltem a MAIN, starfield instantàniament brillant
|
||||
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
|
||||
starfield_->setBrightness(BRIGHTNESS_STARFIELD);
|
||||
} else {
|
||||
// Flux normal: comença con brightness 0.0 per fade-in
|
||||
starfield_->set_brightness(0.0F);
|
||||
starfield_->setBrightness(0.0F);
|
||||
}
|
||||
|
||||
// Inicialitzar animador de naves 3D
|
||||
@@ -76,11 +77,11 @@ TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
||||
|
||||
if (estat_actual_ == TitleState::MAIN) {
|
||||
// Jump to MAIN: empezar entrada inmediatamente
|
||||
ship_animator_->set_visible(true);
|
||||
ship_animator_->start_entry_animation();
|
||||
ship_animator_->setVisible(true);
|
||||
ship_animator_->startEntryAnimation();
|
||||
} else {
|
||||
// Flux normal: NO empezar entrada todavía (esperaran a MAIN)
|
||||
ship_animator_->set_visible(false);
|
||||
ship_animator_->setVisible(false);
|
||||
}
|
||||
|
||||
// Inicialitzar lletres del título "ORNI ATTACK!"
|
||||
@@ -126,7 +127,7 @@ void TitleScene::initTitle() {
|
||||
float min_y = FLT_MAX;
|
||||
float max_y = -FLT_MAX;
|
||||
|
||||
for (const auto& prim : shape->get_primitives()) {
|
||||
for (const auto& prim : shape->getPrimitives()) {
|
||||
for (const auto& point : prim.points) {
|
||||
min_x = std::min(min_x, point.x);
|
||||
max_x = std::max(max_x, point.x);
|
||||
@@ -200,7 +201,7 @@ void TitleScene::initTitle() {
|
||||
float min_y = FLT_MAX;
|
||||
float max_y = -FLT_MAX;
|
||||
|
||||
for (const auto& prim : shape->get_primitives()) {
|
||||
for (const auto& prim : shape->getPrimitives()) {
|
||||
for (const auto& point : prim.points) {
|
||||
min_x = std::min(min_x, point.x);
|
||||
max_x = std::max(max_x, point.x);
|
||||
@@ -284,7 +285,7 @@ void TitleScene::inicialitzarJailgames() {
|
||||
float max_x = -FLT_MAX;
|
||||
float min_y = FLT_MAX;
|
||||
float max_y = -FLT_MAX;
|
||||
for (const auto& prim : shape->get_primitives()) {
|
||||
for (const auto& prim : shape->getPrimitives()) {
|
||||
for (const auto& point : prim.points) {
|
||||
min_x = std::min(min_x, point.x);
|
||||
max_x = std::max(max_x, point.x);
|
||||
@@ -326,7 +327,7 @@ void TitleScene::inicialitzarJailgames() {
|
||||
void TitleScene::dibuixarPeuTitol(float spacing) const {
|
||||
// Logo JAILGAMES pequeño sobre el copyright.
|
||||
for (const auto& lletra : lletres_jailgames_) {
|
||||
Rendering::render_shape(sdl_.getRenderer(), lletra.shape,
|
||||
Rendering::renderShape(sdl_.getRenderer(), lletra.shape,
|
||||
lletra.position, 0.0F,
|
||||
Defaults::Title::Layout::JAILGAMES_SCALE,
|
||||
1.0F);
|
||||
@@ -365,180 +366,200 @@ void TitleScene::update(float delta_time) {
|
||||
}
|
||||
|
||||
switch (estat_actual_) {
|
||||
case TitleState::STARFIELD_FADE_IN: {
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// Calcular progrés del fade (0.0 → 1.0)
|
||||
float progress = std::min(1.0F, temps_acumulat_ / DURACIO_FADE_IN);
|
||||
|
||||
// Lerp brightness de 0.0 a BRIGHTNESS_STARFIELD
|
||||
float brightness_actual = progress * BRIGHTNESS_STARFIELD;
|
||||
starfield_->set_brightness(brightness_actual);
|
||||
|
||||
// Transición a STARFIELD cuando el fade es completa
|
||||
if (temps_acumulat_ >= DURACIO_FADE_IN) {
|
||||
estat_actual_ = TitleState::STARFIELD;
|
||||
temps_acumulat_ = 0.0F; // Reset timer per al següent state
|
||||
starfield_->set_brightness(BRIGHTNESS_STARFIELD); // Assegurar value final
|
||||
}
|
||||
case TitleState::STARFIELD_FADE_IN:
|
||||
updateStarfieldFadeInState(delta_time);
|
||||
break;
|
||||
}
|
||||
|
||||
case TitleState::STARFIELD:
|
||||
temps_acumulat_ += delta_time;
|
||||
if (temps_acumulat_ >= DURACIO_INIT) {
|
||||
estat_actual_ = TitleState::MAIN;
|
||||
temps_estat_main_ = 0.0F; // Reset timer al entrar a MAIN
|
||||
animacio_activa_ = false; // Comença estàtic
|
||||
factor_lerp_ = 0.0F; // Sin animación aún
|
||||
|
||||
// Naves esperaran ENTRANCE_DELAY antes de entrar (no start aquí)
|
||||
}
|
||||
updateStarfieldState(delta_time);
|
||||
break;
|
||||
|
||||
case TitleState::MAIN: {
|
||||
temps_estat_main_ += delta_time;
|
||||
|
||||
// Iniciar animación de entrada de naves después del delay
|
||||
if (temps_estat_main_ >= Defaults::Title::Ships::ENTRANCE_DELAY) {
|
||||
if (ship_animator_ && !ship_animator_->is_visible()) {
|
||||
ship_animator_->set_visible(true);
|
||||
ship_animator_->start_entry_animation();
|
||||
}
|
||||
}
|
||||
|
||||
// Fase 1: Estàtic (0-10s)
|
||||
if (temps_estat_main_ < DELAY_INICI_ANIMACIO) {
|
||||
factor_lerp_ = 0.0F;
|
||||
animacio_activa_ = false;
|
||||
}
|
||||
// Fase 2: Lerp (10-12s)
|
||||
else if (temps_estat_main_ < DELAY_INICI_ANIMACIO + DURACIO_LERP) {
|
||||
float temps_lerp = temps_estat_main_ - DELAY_INICI_ANIMACIO;
|
||||
factor_lerp_ = temps_lerp / DURACIO_LERP; // 0.0 → 1.0 linealment
|
||||
animacio_activa_ = true;
|
||||
}
|
||||
// Fase 3: Animación completa (12s+)
|
||||
else {
|
||||
factor_lerp_ = 1.0F;
|
||||
animacio_activa_ = true;
|
||||
}
|
||||
|
||||
// Actualitzar animación del logo
|
||||
updateLogoAnimation(delta_time);
|
||||
case TitleState::MAIN:
|
||||
updateMainState(delta_time);
|
||||
break;
|
||||
}
|
||||
|
||||
case TitleState::PLAYER_JOIN_PHASE:
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// Continuar animación orbital durante la transición
|
||||
updateLogoAnimation(delta_time);
|
||||
|
||||
// [NOU] Continuar comprovant si l'altre player quiere unir-se durante la transición ("late join")
|
||||
{
|
||||
bool p1_actiu_abans = match_config_.jugador1_actiu;
|
||||
bool p2_actiu_abans = match_config_.jugador2_actiu;
|
||||
|
||||
if (checkStartGameButtonPressed()) {
|
||||
// Updates match_config_ if pressed, logs are in the method
|
||||
context_.setMatchConfig(match_config_);
|
||||
|
||||
// Trigger animación de salida per la ship que acaba de unir-se
|
||||
if (ship_animator_) {
|
||||
if (match_config_.jugador1_actiu && !p1_actiu_abans) {
|
||||
ship_animator_->trigger_exit_animation_for_player(1);
|
||||
std::cout << "[TitleScene] P1 late join - ship exiting\n";
|
||||
}
|
||||
if (match_config_.jugador2_actiu && !p2_actiu_abans) {
|
||||
ship_animator_->trigger_exit_animation_for_player(2);
|
||||
std::cout << "[TitleScene] P2 late join - ship exiting\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Reproducir so de START cuando el segon player s'uneix
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
|
||||
// Reiniciar el timer per allargar el time de transición
|
||||
temps_acumulat_ = 0.0F;
|
||||
|
||||
std::cout << "[TitleScene] Segon player s'ha unit - so i timer reiniciats\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (temps_acumulat_ >= DURACIO_TRANSITION) {
|
||||
// Transición a pantalla negra
|
||||
estat_actual_ = TitleState::BLACK_SCREEN;
|
||||
temps_acumulat_ = 0.0F;
|
||||
std::cout << "[TitleScene] Passant a BLACK_SCREEN\n";
|
||||
}
|
||||
updatePlayerJoinPhaseState(delta_time);
|
||||
break;
|
||||
|
||||
case TitleState::BLACK_SCREEN:
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// No animation, no input checking - just wait
|
||||
if (temps_acumulat_ >= DURACIO_BLACK_SCREEN) {
|
||||
// Transición a escena GAME (el Director detecta isFinished()).
|
||||
context_.setNextScene(SceneType::GAME);
|
||||
std::cout << "[TitleScene] Canviant a escena GAME\n";
|
||||
}
|
||||
updateBlackScreenState(delta_time);
|
||||
break;
|
||||
}
|
||||
|
||||
// Verificar botones de skip (FIRE/THRUST/START) para saltar escenas ANTES de MAIN
|
||||
if (estat_actual_ == TitleState::STARFIELD_FADE_IN || estat_actual_ == TitleState::STARFIELD) {
|
||||
if (checkSkipButtonPressed()) {
|
||||
// Saltar a MAIN
|
||||
estat_actual_ = TitleState::MAIN;
|
||||
starfield_->set_brightness(BRIGHTNESS_STARFIELD);
|
||||
temps_estat_main_ = 0.0F;
|
||||
handleSkipInput();
|
||||
handleStartInput();
|
||||
}
|
||||
|
||||
// Naves esperaran ENTRANCE_DELAY antes de entrar (no start aquí)
|
||||
}
|
||||
void TitleScene::updateStarfieldFadeInState(float delta_time) {
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// Calcular progrés del fade (0.0 → 1.0)
|
||||
float progress = std::min(1.0F, temps_acumulat_ / DURACIO_FADE_IN);
|
||||
|
||||
// Lerp brightness de 0.0 a BRIGHTNESS_STARFIELD
|
||||
float brightness_actual = progress * BRIGHTNESS_STARFIELD;
|
||||
starfield_->setBrightness(brightness_actual);
|
||||
|
||||
// Transición a STARFIELD cuando el fade es completa
|
||||
if (temps_acumulat_ >= DURACIO_FADE_IN) {
|
||||
estat_actual_ = TitleState::STARFIELD;
|
||||
temps_acumulat_ = 0.0F; // Reset timer per al següent state
|
||||
starfield_->setBrightness(BRIGHTNESS_STARFIELD); // Assegurar value final
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::updateStarfieldState(float delta_time) {
|
||||
temps_acumulat_ += delta_time;
|
||||
if (temps_acumulat_ >= DURACIO_INIT) {
|
||||
estat_actual_ = TitleState::MAIN;
|
||||
temps_estat_main_ = 0.0F; // Reset timer al entrar a MAIN
|
||||
animacio_activa_ = false; // Comença estàtic
|
||||
factor_lerp_ = 0.0F; // Sin animación aún
|
||||
|
||||
// Naves esperaran ENTRANCE_DELAY antes de entrar (no start aquí)
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::updateMainState(float delta_time) {
|
||||
temps_estat_main_ += delta_time;
|
||||
|
||||
// Iniciar animación de entrada de naves después del delay
|
||||
if (temps_estat_main_ >= Defaults::Title::Ships::ENTRANCE_DELAY &&
|
||||
ship_animator_ && !ship_animator_->isVisible()) {
|
||||
ship_animator_->setVisible(true);
|
||||
ship_animator_->startEntryAnimation();
|
||||
}
|
||||
|
||||
// Fase 1: Estàtic (0-10s)
|
||||
if (temps_estat_main_ < DELAY_INICI_ANIMACIO) {
|
||||
factor_lerp_ = 0.0F;
|
||||
animacio_activa_ = false;
|
||||
}
|
||||
// Fase 2: Lerp (10-12s)
|
||||
else if (temps_estat_main_ < DELAY_INICI_ANIMACIO + DURACIO_LERP) {
|
||||
float temps_lerp = temps_estat_main_ - DELAY_INICI_ANIMACIO;
|
||||
factor_lerp_ = temps_lerp / DURACIO_LERP; // 0.0 → 1.0 linealment
|
||||
animacio_activa_ = true;
|
||||
}
|
||||
// Fase 3: Animación completa (12s+)
|
||||
else {
|
||||
factor_lerp_ = 1.0F;
|
||||
animacio_activa_ = true;
|
||||
}
|
||||
|
||||
// Actualitzar animación del logo
|
||||
updateLogoAnimation(delta_time);
|
||||
}
|
||||
|
||||
void TitleScene::updatePlayerJoinPhaseState(float delta_time) {
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// Continuar animación orbital durante la transición
|
||||
updateLogoAnimation(delta_time);
|
||||
|
||||
// [NOU] Continuar comprovant si l'altre player quiere unir-se durante la transición ("late join")
|
||||
bool p1_actiu_abans = match_config_.jugador1_actiu;
|
||||
bool p2_actiu_abans = match_config_.jugador2_actiu;
|
||||
|
||||
if (checkStartGameButtonPressed()) {
|
||||
// Updates match_config_ if pressed, logs are in the method
|
||||
context_.setMatchConfig(match_config_);
|
||||
|
||||
// Trigger animación de salida per la ship que acaba de unir-se
|
||||
triggerExitForJoinedPlayers(p1_actiu_abans, p2_actiu_abans, "late join - ");
|
||||
|
||||
// Reproducir so de START cuando el segon player s'uneix
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
|
||||
// Reiniciar el timer per allargar el time de transición
|
||||
temps_acumulat_ = 0.0F;
|
||||
|
||||
std::cout << "[TitleScene] Segon player s'ha unit - so i timer reiniciats\n";
|
||||
}
|
||||
|
||||
if (temps_acumulat_ >= DURACIO_TRANSITION) {
|
||||
// Transición a pantalla negra
|
||||
estat_actual_ = TitleState::BLACK_SCREEN;
|
||||
temps_acumulat_ = 0.0F;
|
||||
std::cout << "[TitleScene] Passant a BLACK_SCREEN\n";
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::updateBlackScreenState(float delta_time) {
|
||||
temps_acumulat_ += delta_time;
|
||||
|
||||
// No animation, no input checking - just wait
|
||||
if (temps_acumulat_ >= DURACIO_BLACK_SCREEN) {
|
||||
// Transición a escena GAME (el Director detecta isFinished()).
|
||||
context_.setNextScene(SceneType::GAME);
|
||||
std::cout << "[TitleScene] Canviant a escena GAME\n";
|
||||
}
|
||||
}
|
||||
|
||||
void TitleScene::handleSkipInput() {
|
||||
// Verificar botones de skip (FIRE/THRUST/START) para saltar escenas ANTES de MAIN
|
||||
if (estat_actual_ != TitleState::STARFIELD_FADE_IN && estat_actual_ != TitleState::STARFIELD) {
|
||||
return;
|
||||
}
|
||||
if (!checkSkipButtonPressed()) {
|
||||
return;
|
||||
}
|
||||
// Saltar a MAIN
|
||||
estat_actual_ = TitleState::MAIN;
|
||||
starfield_->setBrightness(BRIGHTNESS_STARFIELD);
|
||||
temps_estat_main_ = 0.0F;
|
||||
// Naves esperaran ENTRANCE_DELAY antes de entrar (no start aquí)
|
||||
}
|
||||
|
||||
void TitleScene::handleStartInput() {
|
||||
// Verificar boton START para start match desde MAIN
|
||||
if (estat_actual_ == TitleState::MAIN) {
|
||||
// Guardar state anterior per detectar qui ha premut START AQUEST frame
|
||||
bool p1_actiu_abans = match_config_.jugador1_actiu;
|
||||
bool p2_actiu_abans = match_config_.jugador2_actiu;
|
||||
if (estat_actual_ != TitleState::MAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkStartGameButtonPressed()) {
|
||||
// Si START es prem durante el delay (naves aún invisibles), saltar-las a FLOATING
|
||||
if (ship_animator_ && !ship_animator_->is_visible()) {
|
||||
ship_animator_->set_visible(true);
|
||||
ship_animator_->skip_to_floating_state();
|
||||
}
|
||||
// Guardar state anterior per detectar qui ha premut START AQUEST frame
|
||||
bool p1_actiu_abans = match_config_.jugador1_actiu;
|
||||
bool p2_actiu_abans = match_config_.jugador2_actiu;
|
||||
|
||||
// Configurar match antes de canviar de escena
|
||||
context_.setMatchConfig(match_config_);
|
||||
std::cout << "[TitleScene] Configuración de match - P1: "
|
||||
<< (match_config_.jugador1_actiu ? "ACTIU" : "INACTIU")
|
||||
<< ", P2: "
|
||||
<< (match_config_.jugador2_actiu ? "ACTIU" : "INACTIU")
|
||||
<< '\n';
|
||||
if (!checkStartGameButtonPressed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// El setNextScene a GAME se hace al final de BLACK_SCREEN para no
|
||||
// saltar la animación de salida (isFinished() lo recoge entonces).
|
||||
estat_actual_ = TitleState::PLAYER_JOIN_PHASE;
|
||||
temps_acumulat_ = 0.0F;
|
||||
// Si START es prem durante el delay (naves aún invisibles), saltar-las a FLOATING
|
||||
if (ship_animator_ && !ship_animator_->isVisible()) {
|
||||
ship_animator_->setVisible(true);
|
||||
ship_animator_->skipToFloatingState();
|
||||
}
|
||||
|
||||
// Trigger animación de salida NOMÉS per las naves que han premut START
|
||||
if (ship_animator_) {
|
||||
if (match_config_.jugador1_actiu && !p1_actiu_abans) {
|
||||
ship_animator_->trigger_exit_animation_for_player(1);
|
||||
std::cout << "[TitleScene] P1 ship exiting\n";
|
||||
}
|
||||
if (match_config_.jugador2_actiu && !p2_actiu_abans) {
|
||||
ship_animator_->trigger_exit_animation_for_player(2);
|
||||
std::cout << "[TitleScene] P2 ship exiting\n";
|
||||
}
|
||||
}
|
||||
// Configurar match antes de canviar de escena
|
||||
context_.setMatchConfig(match_config_);
|
||||
std::cout << "[TitleScene] Configuración de match - P1: "
|
||||
<< (match_config_.jugador1_actiu ? "ACTIU" : "INACTIU")
|
||||
<< ", P2: "
|
||||
<< (match_config_.jugador2_actiu ? "ACTIU" : "INACTIU")
|
||||
<< '\n';
|
||||
|
||||
Audio::get()->fadeOutMusic(MUSIC_FADE);
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
}
|
||||
// El setNextScene a GAME se hace al final de BLACK_SCREEN para no
|
||||
// saltar la animación de salida (isFinished() lo recoge entonces).
|
||||
estat_actual_ = TitleState::PLAYER_JOIN_PHASE;
|
||||
temps_acumulat_ = 0.0F;
|
||||
|
||||
// Trigger animación de salida NOMÉS per las naves que han premut START
|
||||
triggerExitForJoinedPlayers(p1_actiu_abans, p2_actiu_abans, "");
|
||||
|
||||
Audio::get()->fadeOutMusic(MUSIC_FADE);
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
}
|
||||
|
||||
void TitleScene::triggerExitForJoinedPlayers(bool p1_was_active, bool p2_was_active,
|
||||
const char* log_prefix) {
|
||||
if (ship_animator_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (match_config_.jugador1_actiu && !p1_was_active) {
|
||||
ship_animator_->triggerExitAnimationForPlayer(1);
|
||||
std::cout << "[TitleScene] P1 " << log_prefix << "ship exiting\n";
|
||||
}
|
||||
if (match_config_.jugador2_actiu && !p2_was_active) {
|
||||
ship_animator_->triggerExitAnimationForPlayer(2);
|
||||
std::cout << "[TitleScene] P2 " << log_prefix << "ship exiting\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,7 +639,7 @@ void TitleScene::draw() {
|
||||
pos_shadow.x = posicions_originals_orni_[i].x + static_cast<int>(std::round(shadow_offset_x));
|
||||
pos_shadow.y = posicions_originals_orni_[i].y + static_cast<int>(std::round(shadow_offset_y));
|
||||
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletres_orni_[i].shape,
|
||||
pos_shadow,
|
||||
@@ -635,7 +656,7 @@ void TitleScene::draw() {
|
||||
pos_shadow.x = posicions_originals_attack_[i].x + static_cast<int>(std::round(shadow_offset_x));
|
||||
pos_shadow.y = posicions_originals_attack_[i].y + static_cast<int>(std::round(shadow_offset_y));
|
||||
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletres_attack_[i].shape,
|
||||
pos_shadow,
|
||||
@@ -650,7 +671,7 @@ void TitleScene::draw() {
|
||||
|
||||
// Dibuixar "ORNI" (línia 1)
|
||||
for (const auto& lletra : lletres_orni_) {
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletra.shape,
|
||||
lletra.position,
|
||||
@@ -662,7 +683,7 @@ void TitleScene::draw() {
|
||||
|
||||
// Dibuixar "ATTACK!" (línia 2)
|
||||
for (const auto& lletra : lletres_attack_) {
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
sdl_.getRenderer(),
|
||||
lletra.shape,
|
||||
lletra.position,
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/graphics/shape.hpp"
|
||||
#include "core/graphics/starfield.hpp"
|
||||
#include "core/graphics/vector_text.hpp"
|
||||
@@ -119,4 +118,18 @@ class TitleScene final : public Scene {
|
||||
void initTitle(); // Carrega i posiciona las lletres del título
|
||||
void inicialitzarJailgames(); // Carrega i posiciona el logo JAILGAMES pequeño
|
||||
void dibuixarPeuTitol(float spacing) const; // Logo JAILGAMES + línia de copyright
|
||||
|
||||
// Sub-pasos de update() (extreure cada state per reduir complexitat).
|
||||
void updateStarfieldFadeInState(float delta_time);
|
||||
void updateStarfieldState(float delta_time);
|
||||
void updateMainState(float delta_time);
|
||||
void updatePlayerJoinPhaseState(float delta_time);
|
||||
void updateBlackScreenState(float delta_time);
|
||||
// Handlers de input globals (independents de l'state actual).
|
||||
void handleSkipInput();
|
||||
void handleStartInput();
|
||||
// Helper compartit: dispara l'animación de salida per las naves del player que
|
||||
// acaba de fer un join "en aquest frame" (jugadorX_actiu == true && !prev).
|
||||
void triggerExitForJoinedPlayers(bool p1_was_active, bool p2_was_active,
|
||||
const char* log_prefix);
|
||||
};
|
||||
Reference in new issue
Block a user