refactor: renombra jugador*/zona/radi/MARGE/origen/letra residuals a anglès
This commit is contained in:
1 parent
d36ad7d1c5
commit
252e881e93
22 files changed
+265
-265
No files matched your search
@@ -262,8 +262,8 @@ namespace Systems::Collision {
|
||||
continue;
|
||||
}
|
||||
const bool JUGADOR_ACTIU = (player_id == 0)
|
||||
? ctx.match_config.jugador1_actiu
|
||||
: ctx.match_config.jugador2_actiu;
|
||||
? ctx.match_config.player1_active
|
||||
: ctx.match_config.player2_active;
|
||||
if (!JUGADOR_ACTIU) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -11,99 +11,99 @@
|
||||
#include "game/scenes/game_scene.hpp" // GameOverState (definición completa)
|
||||
|
||||
namespace Systems::ContinueScreen {
|
||||
namespace {
|
||||
namespace {
|
||||
|
||||
// Si el countdown ha bajado de 0, transiciona a GAME_OVER con su timer.
|
||||
void checkAndApplyTimeout(Context& ctx) {
|
||||
if (ctx.counter < 0) {
|
||||
ctx.state = GameOverState::GAME_OVER;
|
||||
ctx.game_over_timer = Defaults::Game::GAME_OVER_DURATION;
|
||||
}
|
||||
}
|
||||
// Si el countdown ha bajado de 0, transiciona a GAME_OVER con su timer.
|
||||
void checkAndApplyTimeout(Context& ctx) {
|
||||
if (ctx.counter < 0) {
|
||||
ctx.state = GameOverState::GAME_OVER;
|
||||
ctx.game_over_timer = Defaults::Game::GAME_OVER_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
void revivePlayer(Context& ctx, uint8_t player_id) {
|
||||
ctx.score_per_player[player_id] = 0;
|
||||
ctx.lives_per_player[player_id] = Defaults::Game::STARTING_LIVES;
|
||||
ctx.hit_timer_per_player[player_id] = 0.0F;
|
||||
void revivePlayer(Context& ctx, uint8_t player_id) {
|
||||
ctx.score_per_player[player_id] = 0;
|
||||
ctx.lives_per_player[player_id] = Defaults::Game::STARTING_LIVES;
|
||||
ctx.hit_timer_per_player[player_id] = 0.0F;
|
||||
|
||||
if (player_id == 0) {
|
||||
ctx.match_config.jugador1_actiu = true;
|
||||
} else {
|
||||
ctx.match_config.jugador2_actiu = true;
|
||||
}
|
||||
if (player_id == 0) {
|
||||
ctx.match_config.player1_active = true;
|
||||
} else {
|
||||
ctx.match_config.player2_active = true;
|
||||
}
|
||||
|
||||
const Vec2 SPAWN = ctx.get_spawn_point(player_id);
|
||||
ctx.ships[player_id].init(&SPAWN, /*activar_invulnerabilitat=*/true);
|
||||
}
|
||||
const Vec2 SPAWN = ctx.get_spawn_point(player_id);
|
||||
ctx.ships[player_id].init(&SPAWN, /*activar_invulnerabilitat=*/true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
void update(Context& ctx, float delta_time) {
|
||||
ctx.tick_timer -= delta_time;
|
||||
if (ctx.tick_timer > 0.0F) {
|
||||
return;
|
||||
}
|
||||
ctx.counter--;
|
||||
ctx.tick_timer = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||
|
||||
checkAndApplyTimeout(ctx);
|
||||
|
||||
// Solo pita el tick si seguimos en CONTINUE (no transitamos a GAME_OVER)
|
||||
if (ctx.state == GameOverState::CONTINUE) {
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
}
|
||||
}
|
||||
|
||||
void processInput(Context& ctx) {
|
||||
auto* input = Input::get();
|
||||
|
||||
const bool P1_START = input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
||||
const bool P2_START = input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
||||
|
||||
if (P1_START || P2_START) {
|
||||
// ¿Quedan continues?
|
||||
if (!Defaults::Game::INFINITE_CONTINUES &&
|
||||
ctx.continues_used >= Defaults::Game::MAX_CONTINUES) {
|
||||
ctx.state = GameOverState::GAME_OVER;
|
||||
ctx.game_over_timer = Defaults::Game::GAME_OVER_DURATION;
|
||||
void update(Context& ctx, float delta_time) {
|
||||
ctx.tick_timer -= delta_time;
|
||||
if (ctx.tick_timer > 0.0F) {
|
||||
return;
|
||||
}
|
||||
if (!Defaults::Game::INFINITE_CONTINUES) {
|
||||
ctx.continues_used++;
|
||||
}
|
||||
|
||||
const uint8_t PRIMARY = P1_START ? 0 : 1;
|
||||
revivePlayer(ctx, PRIMARY);
|
||||
// Si ambos pulsan START, revivimos a los dos.
|
||||
if (P1_START && P2_START) {
|
||||
revivePlayer(ctx, 1);
|
||||
}
|
||||
|
||||
// Reanudar partida.
|
||||
ctx.state = GameOverState::NONE;
|
||||
ctx.counter = 0;
|
||||
ctx.tick_timer = 0.0F;
|
||||
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
return;
|
||||
}
|
||||
|
||||
// THRUST/SHOOT acelera el countdown manualmente.
|
||||
const bool ACCEL = input->checkActionPlayer1(InputAction::THRUST, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer2(InputAction::THRUST, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer1(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer2(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT);
|
||||
|
||||
if (ACCEL) {
|
||||
ctx.counter--;
|
||||
ctx.tick_timer = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||
|
||||
checkAndApplyTimeout(ctx);
|
||||
|
||||
// Solo pita el tick si seguimos en CONTINUE (no transitamos a GAME_OVER)
|
||||
if (ctx.state == GameOverState::CONTINUE) {
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
}
|
||||
|
||||
ctx.tick_timer = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
void processInput(Context& ctx) {
|
||||
auto* input = Input::get();
|
||||
|
||||
const bool P1_START = input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
||||
const bool P2_START = input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT);
|
||||
|
||||
if (P1_START || P2_START) {
|
||||
// ¿Quedan continues?
|
||||
if (!Defaults::Game::INFINITE_CONTINUES &&
|
||||
ctx.continues_used >= Defaults::Game::MAX_CONTINUES) {
|
||||
ctx.state = GameOverState::GAME_OVER;
|
||||
ctx.game_over_timer = Defaults::Game::GAME_OVER_DURATION;
|
||||
return;
|
||||
}
|
||||
if (!Defaults::Game::INFINITE_CONTINUES) {
|
||||
ctx.continues_used++;
|
||||
}
|
||||
|
||||
const uint8_t PRIMARY = P1_START ? 0 : 1;
|
||||
revivePlayer(ctx, PRIMARY);
|
||||
// Si ambos pulsan START, revivimos a los dos.
|
||||
if (P1_START && P2_START) {
|
||||
revivePlayer(ctx, 1);
|
||||
}
|
||||
|
||||
// Reanudar partida.
|
||||
ctx.state = GameOverState::NONE;
|
||||
ctx.counter = 0;
|
||||
ctx.tick_timer = 0.0F;
|
||||
|
||||
Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME);
|
||||
return;
|
||||
}
|
||||
|
||||
// THRUST/SHOOT acelera el countdown manualmente.
|
||||
const bool ACCEL = input->checkActionPlayer1(InputAction::THRUST, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer2(InputAction::THRUST, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer1(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
input->checkActionPlayer2(InputAction::SHOOT, Input::DO_NOT_ALLOW_REPEAT);
|
||||
|
||||
if (ACCEL) {
|
||||
ctx.counter--;
|
||||
checkAndApplyTimeout(ctx);
|
||||
|
||||
if (ctx.state == GameOverState::CONTINUE) {
|
||||
Audio::get()->playSound(Defaults::Sound::CONTINUE, Audio::Group::GAME);
|
||||
}
|
||||
|
||||
ctx.tick_timer = Defaults::Game::CONTINUE_TICK_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Systems::ContinueScreen
|
||||
@@ -31,7 +31,7 @@ namespace Systems::InitHud {
|
||||
auto computeShipPosition(float progress, const Vec2& final_position) -> Vec2 {
|
||||
const float EASED = Easing::easeOutQuad(progress);
|
||||
const SDL_FRect& zone = Defaults::Zones::PLAYAREA;
|
||||
// Y inicial: bajo la zona de juego (sale desde fuera).
|
||||
// Y inicial: bajo la zone de juego (sale desde fuera).
|
||||
const float Y_INI = zone.y + zone.h + Defaults::Hud::InitAnim::SHIP_SPAWN_Y_OFFSET;
|
||||
const float Y_ANIM = Y_INI + ((final_position.y - Y_INI) * EASED);
|
||||
return Vec2{.x = final_position.x, .y = Y_ANIM};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Cubre la animación INIT_HUD del comienzo de cada partida/stage:
|
||||
// 1. Crecimiento de los marcos del PLAYAREA con efecto pincel en 3 fases.
|
||||
// 2. Marcador subiendo desde abajo.
|
||||
// 3. Naves entrando desde la zona inferior hacia su spawn.
|
||||
// 3. Naves entrando desde la zone inferior hacia su spawn.
|
||||
//
|
||||
// Todas las funciones son puras (sin estado interno propio). GameScene aporta
|
||||
// el contexto que necesitan: posiciones finales, texto del scoreboard y el
|
||||
@@ -21,29 +21,29 @@
|
||||
|
||||
namespace Systems::InitHud {
|
||||
|
||||
// Convierte un progreso global 0..1 al sub-progreso de un elemento que solo
|
||||
// se anima en la ventana [ratio_init, ratio_end].
|
||||
// < ratio_init → 0.0 (no empezó)
|
||||
// > ratio_end → 1.0 (terminó)
|
||||
// en rango → interpolación lineal 0..1
|
||||
[[nodiscard]] auto computeRangeProgress(float global_progress,
|
||||
float ratio_init,
|
||||
float ratio_end) -> float;
|
||||
// Convierte un progreso global 0..1 al sub-progreso de un elemento que solo
|
||||
// se anima en la ventana [ratio_init, ratio_end].
|
||||
// < ratio_init → 0.0 (no empezó)
|
||||
// > ratio_end → 1.0 (terminó)
|
||||
// en rango → interpolación lineal 0..1
|
||||
[[nodiscard]] auto computeRangeProgress(float global_progress,
|
||||
float ratio_init,
|
||||
float ratio_end) -> float;
|
||||
|
||||
// Calcula posición Y animada de una nave durante INIT_HUD. La nave sube
|
||||
// desde 50 px bajo el PLAYAREA hasta `final_position` con easing.
|
||||
[[nodiscard]] auto computeShipPosition(float progress, const Vec2& final_position) -> Vec2;
|
||||
// Calcula posición Y animada de una nave durante INIT_HUD. La nave sube
|
||||
// desde 50 px bajo el PLAYAREA hasta `final_position` con easing.
|
||||
[[nodiscard]] auto computeShipPosition(float progress, const Vec2& final_position) -> Vec2;
|
||||
|
||||
// Dibuja los 4 lados del PLAYAREA con efecto pincel en 3 fases:
|
||||
// 0..33% → línea superior crece desde el centro hacia los lados.
|
||||
// 33..66% → líneas verticales bajan por los laterales.
|
||||
// 66..100% → línea inferior crece desde los lados hacia el centro.
|
||||
void drawBordersAnimated(Rendering::Renderer* renderer, float progress);
|
||||
// Dibuja los 4 lados del PLAYAREA con efecto pincel en 3 fases:
|
||||
// 0..33% → línea superior crece desde el centro hacia los lados.
|
||||
// 33..66% → líneas verticales bajan por los laterales.
|
||||
// 66..100% → línea inferior crece desde los lados hacia el centro.
|
||||
void drawBordersAnimated(Rendering::Renderer* renderer, float progress);
|
||||
|
||||
// Dibuja el scoreboard centrado, subiendo desde fuera de la pantalla
|
||||
// hasta su posición final con easing.
|
||||
void drawScoreboardAnimated(const Graphics::VectorText& text,
|
||||
const std::string& scoreboard_text,
|
||||
float progress);
|
||||
// Dibuja el scoreboard centrado, subiendo desde fuera de la pantalla
|
||||
// hasta su posición final con easing.
|
||||
void drawScoreboardAnimated(const Graphics::VectorText& text,
|
||||
const std::string& scoreboard_text,
|
||||
float progress);
|
||||
|
||||
} // namespace Systems::InitHud
|
||||
Reference in new issue
Block a user