refactor: renombra jugador*/zona/radi/MARGE/origen/letra residuals a anglès
This commit is contained in:
@@ -38,9 +38,9 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
|
||||
// Debug output de la configuración
|
||||
std::cout << "[GameScene] Configuración de match - P1: "
|
||||
<< (match_config_.jugador1_actiu ? "ACTIU" : "INACTIU")
|
||||
<< (match_config_.player1_active ? "ACTIU" : "INACTIU")
|
||||
<< ", P2: "
|
||||
<< (match_config_.jugador2_actiu ? "ACTIU" : "INACTIU")
|
||||
<< (match_config_.player2_active ? "ACTIU" : "INACTIU")
|
||||
<< '\n';
|
||||
|
||||
// Consumir opciones (preparació per MODE_DEMO futur)
|
||||
@@ -61,7 +61,7 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
// Basat en el codi Pascal original: line 376
|
||||
std::srand(static_cast<unsigned>(std::time(nullptr)));
|
||||
|
||||
// Configurar el mundo físico con los límites de la zona de juego.
|
||||
// Configurar el mundo físico con los límites de la zone de juego.
|
||||
physics_world_.clear();
|
||||
physics_world_.setBounds(Defaults::Zones::PLAYAREA);
|
||||
|
||||
@@ -77,17 +77,17 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
});
|
||||
|
||||
// Fireworks generen una ripple gran al playfield (ona d'aigua centrada al burst).
|
||||
firework_manager_.setSpawnCallback([this](Vec2 origen) {
|
||||
playfield_.notifyExplosion(origen);
|
||||
firework_manager_.setSpawnCallback([this](Vec2 origin) {
|
||||
playfield_.notifyExplosion(origin);
|
||||
});
|
||||
|
||||
// Explosions properes a una paret també generen bump (falloff lineal amb la distància).
|
||||
debris_manager_.setExplosionCallback([this](Vec2 center) {
|
||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||
const float DIST_LEFT = std::abs(center.x - zona.x);
|
||||
const float DIST_RIGHT = std::abs((zona.x + zona.w) - center.x);
|
||||
const float DIST_TOP = std::abs(center.y - zona.y);
|
||||
const float DIST_BOTTOM = std::abs((zona.y + zona.h) - center.y);
|
||||
const SDL_FRect& zone = Defaults::Zones::PLAYAREA;
|
||||
const float DIST_LEFT = std::abs(center.x - zone.x);
|
||||
const float DIST_RIGHT = std::abs((zone.x + zone.w) - center.x);
|
||||
const float DIST_TOP = std::abs(center.y - zone.y);
|
||||
const float DIST_BOTTOM = std::abs((zone.y + zone.h) - center.y);
|
||||
const float MIN_DIST = std::min({DIST_LEFT, DIST_RIGHT, DIST_TOP, DIST_BOTTOM});
|
||||
if (MIN_DIST > Defaults::Border::EXPLOSION_FALLOFF_PX) {
|
||||
return;
|
||||
@@ -130,9 +130,9 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
|
||||
// Inicialitzar naves segons configuración (solo jugadors active)
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
bool jugador_actiu = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
bool player_active = (i == 0) ? match_config_.player1_active : match_config_.player2_active;
|
||||
|
||||
if (jugador_actiu) {
|
||||
if (player_active) {
|
||||
// Jugador active: init normalment
|
||||
Vec2 spawn_pos = getSpawnPoint(i);
|
||||
ships_[i].init(&spawn_pos, false); // No invulnerability at start
|
||||
@@ -248,11 +248,11 @@ void GameScene::stepPhysics(float delta_time) {
|
||||
|
||||
void GameScene::stepShootingInput() {
|
||||
auto* input = Input::get();
|
||||
if (match_config_.jugador1_actiu &&
|
||||
if (match_config_.player1_active &&
|
||||
input->checkActionPlayer1(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
fireBullet(0);
|
||||
}
|
||||
if (match_config_.jugador2_actiu &&
|
||||
if (match_config_.player2_active &&
|
||||
input->checkActionPlayer2(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
fireBullet(1);
|
||||
}
|
||||
@@ -267,16 +267,16 @@ void GameScene::stepMidGameJoin() {
|
||||
// Solo se permite join si hay al menos un jugador vivo (no se puede
|
||||
// hacer join en pantalla vacía).
|
||||
const bool ALGU_VIU =
|
||||
(match_config_.jugador1_actiu && hit_timer_per_player_[0] != Defaults::Game::HIT_TIMER_INACTIVE_PLAYER) ||
|
||||
(match_config_.jugador2_actiu && hit_timer_per_player_[1] != Defaults::Game::HIT_TIMER_INACTIVE_PLAYER);
|
||||
(match_config_.player1_active && hit_timer_per_player_[0] != Defaults::Game::HIT_TIMER_INACTIVE_PLAYER) ||
|
||||
(match_config_.player2_active && hit_timer_per_player_[1] != Defaults::Game::HIT_TIMER_INACTIVE_PLAYER);
|
||||
if (!ALGU_VIU) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* input = Input::get();
|
||||
for (uint8_t pid = 0; pid < 2; pid++) {
|
||||
const bool ACTIU = (pid == 0) ? match_config_.jugador1_actiu
|
||||
: match_config_.jugador2_actiu;
|
||||
const bool ACTIU = (pid == 0) ? match_config_.player1_active
|
||||
: match_config_.player2_active;
|
||||
const bool MUERTO_SIN_VIDAS = hit_timer_per_player_[pid] == Defaults::Game::HIT_TIMER_INACTIVE_PLAYER;
|
||||
if (ACTIU && !MUERTO_SIN_VIDAS) {
|
||||
continue; // jugador ya está jugando
|
||||
@@ -375,8 +375,8 @@ void GameScene::stepDeathSequence(float delta_time) {
|
||||
|
||||
// Sin vidas: marcar definitivamente muerto y comprobar transición a CONTINUE.
|
||||
hit_timer_per_player_[i] = Defaults::Game::HIT_TIMER_INACTIVE_PLAYER;
|
||||
const bool P1_DEAD = !match_config_.jugador1_actiu || lives_per_player_[0] <= 0;
|
||||
const bool P2_DEAD = !match_config_.jugador2_actiu || lives_per_player_[1] <= 0;
|
||||
const bool P1_DEAD = !match_config_.player1_active || lives_per_player_[0] <= 0;
|
||||
const bool P2_DEAD = !match_config_.player2_active || lives_per_player_[1] <= 0;
|
||||
if (P1_DEAD && P2_DEAD) {
|
||||
game_over_state_ = GameOverState::CONTINUE;
|
||||
continue_counter_ = Defaults::Game::CONTINUE_COUNT_START;
|
||||
@@ -440,10 +440,10 @@ void GameScene::runStageInitHud(float delta_time) {
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_INIT,
|
||||
Defaults::Game::INIT_HUD_SHIP2_RATIO_END);
|
||||
|
||||
if (match_config_.jugador1_actiu && SHIP1_P < 1.0F) {
|
||||
if (match_config_.player1_active && SHIP1_P < 1.0F) {
|
||||
ships_[0].setCenter(Systems::InitHud::computeShipPosition(SHIP1_P, getSpawnPoint(0)));
|
||||
}
|
||||
if (match_config_.jugador2_actiu && SHIP2_P < 1.0F) {
|
||||
if (match_config_.player2_active && SHIP2_P < 1.0F) {
|
||||
ships_[1].setCenter(Systems::InitHud::computeShipPosition(SHIP2_P, getSpawnPoint(1)));
|
||||
}
|
||||
}
|
||||
@@ -453,7 +453,7 @@ void GameScene::runStageLevelStart(float delta_time) {
|
||||
|
||||
// Ambas naves pueden moverse y disparar durante el intro.
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
const bool ACTIU = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
const bool ACTIU = (i == 0) ? match_config_.player1_active : match_config_.player2_active;
|
||||
if (ACTIU && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].processInput(delta_time, i);
|
||||
ships_[i].update(delta_time);
|
||||
@@ -481,7 +481,7 @@ void GameScene::runStagePlaying(float delta_time) {
|
||||
|
||||
// Gameplay normal: ships activos + entidades + colisiones + efectos.
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
const bool ACTIU = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
const bool ACTIU = (i == 0) ? match_config_.player1_active : match_config_.player2_active;
|
||||
if (ACTIU && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].processInput(delta_time, i);
|
||||
ships_[i].update(delta_time);
|
||||
@@ -491,7 +491,7 @@ void GameScene::runStagePlaying(float delta_time) {
|
||||
enemy.update(delta_time);
|
||||
}
|
||||
|
||||
// Col·lisions primer, després desactivació per fora-de-zona: així una bala que
|
||||
// Col·lisions primer, després desactivació per fora-de-zone: així una bala que
|
||||
// el mateix frame xoca amb un enemic i alhora surt del PLAYAREA es compta com a
|
||||
// impacte abans no se la trenqui per sortir.
|
||||
runCollisionDetections();
|
||||
@@ -507,7 +507,7 @@ void GameScene::runStagePlaying(float delta_time) {
|
||||
void GameScene::runStageLevelCompleted(float delta_time) {
|
||||
stage_manager_->update(delta_time);
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
const bool ACTIU = (i == 0) ? match_config_.jugador1_actiu : match_config_.jugador2_actiu;
|
||||
const bool ACTIU = (i == 0) ? match_config_.player1_active : match_config_.player2_active;
|
||||
if (ACTIU && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].processInput(delta_time, i);
|
||||
ships_[i].update(delta_time);
|
||||
@@ -580,8 +580,8 @@ void GameScene::drawBullets() const {
|
||||
|
||||
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) {
|
||||
bool player_active = (i == 0) ? match_config_.player1_active : match_config_.player2_active;
|
||||
if (player_active && hit_timer_per_player_[i] == 0.0F) {
|
||||
ships_[i].draw();
|
||||
}
|
||||
}
|
||||
@@ -613,10 +613,10 @@ void GameScene::drawGameOverState() {
|
||||
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);
|
||||
float center_x = play_area.x + (play_area.w / 2.0F);
|
||||
float center_y = play_area.y + (play_area.h / 2.0F);
|
||||
|
||||
text_.renderCentered(GAME_OVER_TEXT, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||
text_.renderCentered(GAME_OVER_TEXT, {.x = center_x, .y = center_y}, SCALE, SPACING);
|
||||
|
||||
drawScoreboard();
|
||||
}
|
||||
@@ -663,11 +663,11 @@ void GameScene::drawInitHudState() {
|
||||
Systems::InitHud::drawScoreboardAnimated(text_, buildScoreboard(), score_progress);
|
||||
}
|
||||
|
||||
if (ship1_progress > 0.0F && match_config_.jugador1_actiu && ships_[0].isActive()) {
|
||||
if (ship1_progress > 0.0F && match_config_.player1_active && ships_[0].isActive()) {
|
||||
ships_[0].draw();
|
||||
}
|
||||
|
||||
if (ship2_progress > 0.0F && match_config_.jugador2_actiu && ships_[1].isActive()) {
|
||||
if (ship2_progress > 0.0F && match_config_.player2_active && ships_[1].isActive()) {
|
||||
ships_[1].draw();
|
||||
}
|
||||
}
|
||||
@@ -769,20 +769,20 @@ void GameScene::drawScoreboard() {
|
||||
const float SCALE = Defaults::Hud::SCOREBOARD_TEXT_SCALE;
|
||||
const float SPACING = Defaults::Hud::SCOREBOARD_TEXT_SPACING;
|
||||
|
||||
// Calcular centro de la zona del marcador
|
||||
// Calcular centro de la zone del marcador
|
||||
const SDL_FRect& scoreboard_zone = Defaults::Zones::SCOREBOARD;
|
||||
float centre_x = scoreboard_zone.w / 2.0F;
|
||||
float centre_y = scoreboard_zone.y + (scoreboard_zone.h / 2.0F);
|
||||
float center_x = scoreboard_zone.w / 2.0F;
|
||||
float center_y = scoreboard_zone.y + (scoreboard_zone.h / 2.0F);
|
||||
|
||||
// Renderizar centrat
|
||||
text_.renderCentered(text, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||
text_.renderCentered(text, {.x = center_x, .y = center_y}, SCALE, SPACING);
|
||||
}
|
||||
|
||||
auto GameScene::buildScoreboard() const -> std::string {
|
||||
// Puntuación P1 (6 dígits) - mostrar zeros si inactiu
|
||||
std::string score_p1;
|
||||
std::string vides_p1;
|
||||
if (match_config_.jugador1_actiu) {
|
||||
if (match_config_.player1_active) {
|
||||
score_p1 = std::to_string(score_per_player_[0]);
|
||||
score_p1 = std::string(6 - std::min(6, static_cast<int>(score_p1.length())), '0') + score_p1;
|
||||
vides_p1 = (lives_per_player_[0] < 10)
|
||||
@@ -801,7 +801,7 @@ auto GameScene::buildScoreboard() const -> std::string {
|
||||
// Puntuación P2 (6 dígits) - mostrar zeros si inactiu
|
||||
std::string score_p2;
|
||||
std::string vides_p2;
|
||||
if (match_config_.jugador2_actiu) {
|
||||
if (match_config_.player2_active) {
|
||||
score_p2 = std::to_string(score_per_player_[1]);
|
||||
score_p2 = std::string(6 - std::min(6, static_cast<int>(score_p2.length())), '0') + score_p2;
|
||||
vides_p2 = (lives_per_player_[1] < 10)
|
||||
@@ -890,7 +890,7 @@ void GameScene::drawStageMessage(const std::string& message) {
|
||||
// ========================================
|
||||
|
||||
auto GameScene::getSpawnPoint(uint8_t player_id) const -> Vec2 {
|
||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||
const SDL_FRect& zone = Defaults::Zones::PLAYAREA;
|
||||
|
||||
float x_ratio;
|
||||
if (match_config_.isSinglePlayer()) {
|
||||
@@ -904,8 +904,8 @@ auto GameScene::getSpawnPoint(uint8_t player_id) const -> Vec2 {
|
||||
}
|
||||
|
||||
return {
|
||||
.x = zona.x + (zona.w * x_ratio),
|
||||
.y = zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
|
||||
.x = zone.x + (zone.w * x_ratio),
|
||||
.y = zone.y + (zone.h * Defaults::Game::SPAWN_Y_RATIO)};
|
||||
}
|
||||
|
||||
void GameScene::fireBullet(uint8_t player_id) {
|
||||
@@ -950,10 +950,10 @@ void GameScene::drawContinue() {
|
||||
float escala_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_SCALE;
|
||||
float y_ratio_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_Y_RATIO;
|
||||
|
||||
float centre_x = play_area.x + (play_area.w / 2.0F);
|
||||
float center_x = play_area.x + (play_area.w / 2.0F);
|
||||
float centre_y_continue = play_area.y + (play_area.h * y_ratio_continue);
|
||||
|
||||
text_.renderCentered(CONTINUE_TEXT, {.x = centre_x, .y = centre_y_continue}, escala_continue, SPACING);
|
||||
text_.renderCentered(CONTINUE_TEXT, {.x = center_x, .y = centre_y_continue}, escala_continue, SPACING);
|
||||
|
||||
// Countdown number (using constants)
|
||||
const std::string COUNTER_STR = std::to_string(continue_counter_);
|
||||
@@ -962,7 +962,7 @@ void GameScene::drawContinue() {
|
||||
|
||||
float centre_y_counter = play_area.y + (play_area.h * y_ratio_counter);
|
||||
|
||||
text_.renderCentered(COUNTER_STR, {.x = centre_x, .y = centre_y_counter}, escala_counter, SPACING);
|
||||
text_.renderCentered(COUNTER_STR, {.x = center_x, .y = centre_y_counter}, escala_counter, SPACING);
|
||||
|
||||
// "CONTINUES LEFT" (conditional + using constants)
|
||||
if (!Defaults::Game::INFINITE_CONTINUES) {
|
||||
@@ -972,16 +972,16 @@ void GameScene::drawContinue() {
|
||||
|
||||
float centre_y_info = play_area.y + (play_area.h * y_ratio_info);
|
||||
|
||||
text_.renderCentered(CONTINUES_TEXT, {.x = centre_x, .y = centre_y_info}, escala_info, SPACING);
|
||||
text_.renderCentered(CONTINUES_TEXT, {.x = center_x, .y = centre_y_info}, escala_info, SPACING);
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::joinPlayer(uint8_t player_id) {
|
||||
// Activate player
|
||||
if (player_id == 0) {
|
||||
match_config_.jugador1_actiu = true;
|
||||
match_config_.player1_active = true;
|
||||
} else {
|
||||
match_config_.jugador2_actiu = true;
|
||||
match_config_.player2_active = true;
|
||||
}
|
||||
|
||||
// Reset stats
|
||||
|
||||
Reference in New Issue
Block a user