clang-tidy
This commit is contained in:
@@ -170,9 +170,8 @@ void Credits::fillTextTexture() {
|
||||
const int TEXTS_HEIGHT = 1 * text->getCharacterSize() + 8 * SPACE_POST_TITLE + 3 * SPACE_PRE_TITLE;
|
||||
credits_rect_dst_.h = credits_rect_src_.h = TEXTS_HEIGHT;
|
||||
|
||||
int y = (param.game.height - TEXTS_HEIGHT) / 2;
|
||||
// PROGRAMMED_AND_DESIGNED_BY
|
||||
y = 0;
|
||||
int y = 0;
|
||||
text_grad->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(0), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR);
|
||||
|
||||
y += SPACE_POST_TITLE;
|
||||
@@ -259,7 +258,7 @@ void Credits::fillCanvas() {
|
||||
// SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF);
|
||||
const Color COLOR = color_.LIGHTEN();
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), COLOR.r, COLOR.g, COLOR.b, 0xFF);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &red_rect);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &border_rect_);
|
||||
|
||||
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior
|
||||
if (mini_logo_on_position_) {
|
||||
@@ -408,10 +407,10 @@ void Credits::updateBlackRects() {
|
||||
|
||||
// Actualiza el rectangulo rojo
|
||||
void Credits::updateRedRect() {
|
||||
red_rect.x = left_black_rect_.x + left_black_rect_.w;
|
||||
red_rect.y = top_black_rect_.y + top_black_rect_.h - 1;
|
||||
red_rect.w = right_black_rect_.x - red_rect.x;
|
||||
red_rect.h = bottom_black_rect_.y - red_rect.y + 1;
|
||||
border_rect_.x = left_black_rect_.x + left_black_rect_.w;
|
||||
border_rect_.y = top_black_rect_.y + top_black_rect_.h - 1;
|
||||
border_rect_.w = right_black_rect_.x - border_rect_.x;
|
||||
border_rect_.h = bottom_black_rect_.y - border_rect_.y + 1;
|
||||
}
|
||||
|
||||
// Actualiza el estado de fade
|
||||
|
||||
@@ -16,114 +16,114 @@ class Player;
|
||||
class TiledBG;
|
||||
|
||||
class Credits {
|
||||
public:
|
||||
// --- Constructores y destructor ---
|
||||
Credits();
|
||||
~Credits();
|
||||
public:
|
||||
// --- Constructores y destructor ---
|
||||
Credits();
|
||||
~Credits();
|
||||
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
// --- Bucle principal ---
|
||||
void run();
|
||||
|
||||
private:
|
||||
// --- Constantes de clase ---
|
||||
static constexpr int PLAY_AREA_HEIGHT = 200;
|
||||
private:
|
||||
// --- Constantes de clase ---
|
||||
static constexpr int PLAY_AREA_HEIGHT = 200;
|
||||
|
||||
// --- Objetos principales ---
|
||||
std::unique_ptr<BalloonManager> balloon_manager_; // Gestión de globos
|
||||
std::unique_ptr<TiledBG> tiled_bg_; // Mosaico animado de fondo
|
||||
std::unique_ptr<Fade> fade_in_; // Fundido de entrada
|
||||
std::unique_ptr<Fade> fade_out_; // Fundido de salida
|
||||
std::vector<std::shared_ptr<Player>> players_; // Vector de jugadores
|
||||
// --- Objetos principales ---
|
||||
std::unique_ptr<BalloonManager> balloon_manager_; // Gestión de globos
|
||||
std::unique_ptr<TiledBG> tiled_bg_; // Mosaico animado de fondo
|
||||
std::unique_ptr<Fade> fade_in_; // Fundido de entrada
|
||||
std::unique_ptr<Fade> fade_out_; // Fundido de salida
|
||||
std::vector<std::shared_ptr<Player>> players_; // Vector de jugadores
|
||||
|
||||
// --- Gestión de texturas ---
|
||||
SDL_Texture *text_texture_; // Textura con el texto de créditos
|
||||
SDL_Texture *canvas_; // Textura donde se dibuja todo
|
||||
// --- Gestión de texturas ---
|
||||
SDL_Texture *text_texture_; // Textura con el texto de créditos
|
||||
SDL_Texture *canvas_; // Textura donde se dibuja todo
|
||||
|
||||
// --- Temporización y contadores ---
|
||||
Uint64 ticks_ = 0; // Control de velocidad del programa
|
||||
Uint32 counter_ = 0; // Contador principal de lógica
|
||||
Uint32 counter_pre_fade_ = 0; // Activación del fundido final
|
||||
Uint32 counter_prevent_endless_ = 0; // Prevención de bucle infinito
|
||||
// --- Temporización y contadores ---
|
||||
Uint64 ticks_ = 0; // Control de velocidad del programa
|
||||
Uint32 counter_ = 0; // Contador principal de lógica
|
||||
Uint32 counter_pre_fade_ = 0; // Activación del fundido final
|
||||
Uint32 counter_prevent_endless_ = 0; // Prevención de bucle infinito
|
||||
|
||||
// --- Variables de estado ---
|
||||
bool fading_ = false; // Estado del fade final
|
||||
bool want_to_pass_ = false; // Jugador quiere saltarse créditos
|
||||
bool mini_logo_on_position_ = false; // Minilogo en posición final
|
||||
// --- Variables de estado ---
|
||||
bool fading_ = false; // Estado del fade final
|
||||
bool want_to_pass_ = false; // Jugador quiere saltarse créditos
|
||||
bool mini_logo_on_position_ = false; // Minilogo en posición final
|
||||
|
||||
// --- Diseño y posicionamiento ---
|
||||
float black_bars_size_ = (param.game.game_area.rect.h - PLAY_AREA_HEIGHT) / 2; // Tamaño de las barras negras
|
||||
int mini_logo_final_pos_ = 0; // Posición final del minilogo
|
||||
Color color_; // Color usado para los efectos
|
||||
// --- Diseño y posicionamiento ---
|
||||
float black_bars_size_ = (param.game.game_area.rect.h - PLAY_AREA_HEIGHT) / 2; // Tamaño de las barras negras
|
||||
int mini_logo_final_pos_ = 0; // Posición final del minilogo
|
||||
Color color_; // Color usado para los efectos
|
||||
|
||||
// --- Control de audio ---
|
||||
int initial_volume_ = Options::audio.music.volume; // Volumen inicial
|
||||
int steps_ = 0; // Pasos para reducir audio
|
||||
// --- Control de audio ---
|
||||
int initial_volume_ = Options::audio.music.volume; // Volumen inicial
|
||||
int steps_ = 0; // Pasos para reducir audio
|
||||
|
||||
// --- Rectángulos de renderizado ---
|
||||
// Texto de créditos
|
||||
SDL_FRect credits_rect_src_ = param.game.game_area.rect;
|
||||
SDL_FRect credits_rect_dst_ = param.game.game_area.rect;
|
||||
// --- Rectángulos de renderizado ---
|
||||
// Texto de créditos
|
||||
SDL_FRect credits_rect_src_ = param.game.game_area.rect;
|
||||
SDL_FRect credits_rect_dst_ = param.game.game_area.rect;
|
||||
|
||||
// Mini logo
|
||||
SDL_FRect mini_logo_rect_src_ = param.game.game_area.rect;
|
||||
SDL_FRect mini_logo_rect_dst_ = param.game.game_area.rect;
|
||||
// Mini logo
|
||||
SDL_FRect mini_logo_rect_src_ = param.game.game_area.rect;
|
||||
SDL_FRect mini_logo_rect_dst_ = param.game.game_area.rect;
|
||||
|
||||
// Definición del área de juego
|
||||
SDL_FRect play_area_ = {
|
||||
param.game.game_area.rect.x,
|
||||
param.game.game_area.rect.y + black_bars_size_,
|
||||
param.game.game_area.rect.w,
|
||||
PLAY_AREA_HEIGHT};
|
||||
// Definición del área de juego
|
||||
SDL_FRect play_area_ = {
|
||||
param.game.game_area.rect.x,
|
||||
param.game.game_area.rect.y + black_bars_size_,
|
||||
param.game.game_area.rect.w,
|
||||
PLAY_AREA_HEIGHT};
|
||||
|
||||
// Barras negras para efecto letterbox
|
||||
SDL_FRect top_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.y,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
SDL_FRect bottom_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.h - black_bars_size_,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
SDL_FRect left_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
SDL_FRect right_black_rect_ = {
|
||||
play_area_.x + play_area_.w,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
// Barras negras para efecto letterbox
|
||||
SDL_FRect top_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.y,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
SDL_FRect bottom_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.rect.h - black_bars_size_,
|
||||
play_area_.w,
|
||||
black_bars_size_};
|
||||
SDL_FRect left_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
SDL_FRect right_black_rect_ = {
|
||||
play_area_.x + play_area_.w,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
|
||||
// Borde para la ventana
|
||||
SDL_FRect red_rect = play_area_; // Delimitador de ventana
|
||||
// Borde para la ventana
|
||||
SDL_FRect border_rect_ = play_area_; // Delimitador de ventana
|
||||
|
||||
// --- Métodos del bucle principal ---
|
||||
void update(); // Actualización principal de la lógica
|
||||
void render(); // Renderizado de la escena
|
||||
void checkEvents(); // Manejo de eventos
|
||||
void checkInput(); // Procesamiento de entrada
|
||||
// --- Métodos del bucle principal ---
|
||||
void update(); // Actualización principal de la lógica
|
||||
void render(); // Renderizado de la escena
|
||||
void checkEvents(); // Manejo de eventos
|
||||
void checkInput(); // Procesamiento de entrada
|
||||
|
||||
// --- Métodos de renderizado ---
|
||||
void fillTextTexture(); // Crear textura de texto de créditos
|
||||
void fillCanvas(); // Renderizar todos los sprites y fondos
|
||||
void updateTextureDstRects(); // Actualizar destinos de texturas
|
||||
void renderPlayers(); // Renderiza los jugadores
|
||||
// --- Métodos de renderizado ---
|
||||
void fillTextTexture(); // Crear textura de texto de créditos
|
||||
void fillCanvas(); // Renderizar todos los sprites y fondos
|
||||
void updateTextureDstRects(); // Actualizar destinos de texturas
|
||||
void renderPlayers(); // Renderiza los jugadores
|
||||
|
||||
// --- Métodos de lógica del juego ---
|
||||
void throwBalloons(); // Lanzar globos al escenario
|
||||
void initPlayers(); // Inicializar jugadores
|
||||
void updateAllFades(); // Actualizar estados de fade
|
||||
void cycleColors(); // Cambiar colores de fondo
|
||||
void updatePlayers(); // Actualza los jugadores
|
||||
// --- Métodos de lógica del juego ---
|
||||
void throwBalloons(); // Lanzar globos al escenario
|
||||
void initPlayers(); // Inicializar jugadores
|
||||
void updateAllFades(); // Actualizar estados de fade
|
||||
void cycleColors(); // Cambiar colores de fondo
|
||||
void updatePlayers(); // Actualza los jugadores
|
||||
|
||||
// --- Métodos de interfaz ---
|
||||
void updateBlackRects(); // Actualizar rectángulos negros (letterbox)
|
||||
void updateRedRect(); // Actualizar rectángulo rojo (borde)
|
||||
// --- Métodos de interfaz ---
|
||||
void updateBlackRects(); // Actualizar rectángulos negros (letterbox)
|
||||
void updateRedRect(); // Actualizar rectángulo rojo (borde)
|
||||
|
||||
// --- Métodos de audio ---
|
||||
void setVolume(int amount); // Establecer volumen
|
||||
void resetVolume(); // Restablecer volumen
|
||||
// --- Métodos de audio ---
|
||||
void setVolume(int amount); // Establecer volumen
|
||||
void resetVolume(); // Restablecer volumen
|
||||
};
|
||||
@@ -283,7 +283,7 @@ void Game::updateGameStateGameOver() {
|
||||
cleanVectors();
|
||||
|
||||
if (game_over_counter_ > 0) {
|
||||
if (game_over_counter_ == GAME_OVER_COUNTER_) {
|
||||
if (game_over_counter_ == GAME_OVER_COUNTER) {
|
||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
||||
Audio::get()->fadeOutMusic(1000);
|
||||
balloon_manager_->setBouncingSounds(true);
|
||||
@@ -367,7 +367,7 @@ void Game::updateGameStateCompleted() {
|
||||
if (game_completed_counter_ == END_CELEBRATIONS) {
|
||||
for (auto &player : players_) {
|
||||
if (player->isCelebrating()) {
|
||||
player->setPlayingState(player->IsEligibleForHighScore() ? PlayerState::ENTERING_NAME_GAME_COMPLETED : PlayerState::LEAVING_SCREEN);
|
||||
player->setPlayingState(player->isEligibleForHighScore() ? PlayerState::ENTERING_NAME_GAME_COMPLETED : PlayerState::LEAVING_SCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -621,7 +621,7 @@ ItemType Game::dropItem() {
|
||||
break;
|
||||
case 4:
|
||||
if (LUCKY_NUMBER < helper_.item_coffee_odds) {
|
||||
helper_.item_coffee_odds = ITEM_COFFEE_ODDS_;
|
||||
helper_.item_coffee_odds = ITEM_COFFEE_ODDS;
|
||||
return ItemType::COFFEE;
|
||||
} else {
|
||||
if (helper_.need_coffee) {
|
||||
@@ -631,7 +631,7 @@ ItemType Game::dropItem() {
|
||||
break;
|
||||
case 5:
|
||||
if (LUCKY_NUMBER < helper_.item_coffee_machine_odds) {
|
||||
helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS_;
|
||||
helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS;
|
||||
if (!coffee_machine_enabled_ && helper_.need_coffee_machine) {
|
||||
return ItemType::COFFEE_MACHINE;
|
||||
}
|
||||
@@ -786,7 +786,7 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player) {
|
||||
screen_->shake();
|
||||
playSound("voice_no.wav");
|
||||
player->setPlayingState(PlayerState::ROLLING);
|
||||
players_to_reorder.push_back(player);
|
||||
players_to_reorder_.push_back(player);
|
||||
if (allPlayersAreNotPlaying()) {
|
||||
// No se puede subir poder de fase si no hay nadie jugando
|
||||
Stage::power_can_be_added = false;
|
||||
@@ -928,7 +928,7 @@ void Game::render() {
|
||||
void Game::enableTimeStopItem() {
|
||||
balloon_manager_->stopAllBalloons();
|
||||
balloon_manager_->reverseColorsToAllBalloons();
|
||||
time_stopped_counter_ = TIME_STOPPED_COUNTER_;
|
||||
time_stopped_counter_ = TIME_STOPPED_COUNTER;
|
||||
}
|
||||
|
||||
// Deshabilita el efecto del item de detener el tiempo
|
||||
@@ -1158,12 +1158,12 @@ void Game::checkInput() {
|
||||
// Comprueba las entradas si no está el menú de servicio activo
|
||||
if (!ServiceMenu::get()->isEnabled()) {
|
||||
checkPauseInput();
|
||||
demo_.enabled ? DEMO_handlePassInput() : handlePlayersInput();
|
||||
demo_.enabled ? demoHandlePassInput() : handlePlayersInput();
|
||||
}
|
||||
|
||||
// Mueve los jugadores en el modo demo
|
||||
if (demo_.enabled) {
|
||||
DEMO_handleInput();
|
||||
demoHandleInput();
|
||||
}
|
||||
|
||||
// Verifica los inputs globales.
|
||||
@@ -1188,7 +1188,7 @@ void Game::checkPauseInput() {
|
||||
}
|
||||
|
||||
// Gestiona las entradas de los jugadores en el modo demo para saltarse la demo.
|
||||
void Game::DEMO_handlePassInput() {
|
||||
void Game::demoHandlePassInput() {
|
||||
if (input_->checkAnyButton()) {
|
||||
Section::name = Section::Name::TITLE; // Salir del modo demo y regresar al menú principal.
|
||||
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO; // El juego volverá a mostrar la demo
|
||||
@@ -1197,19 +1197,19 @@ void Game::DEMO_handlePassInput() {
|
||||
}
|
||||
|
||||
// Gestiona las entradas de los jugadores en el modo demo, incluyendo movimientos y disparos automáticos.
|
||||
void Game::DEMO_handleInput() {
|
||||
void Game::demoHandleInput() {
|
||||
int index = 0;
|
||||
for (const auto &player : players_) {
|
||||
if (player->isPlaying()) {
|
||||
// Maneja el input específico del jugador en modo demo.
|
||||
DEMO_handlePlayerInput(player, index);
|
||||
demoHandlePlayerInput(player, index);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
// Procesa las entradas para un jugador específico durante el modo demo.
|
||||
void Game::DEMO_handlePlayerInput(const std::shared_ptr<Player> &player, int index) {
|
||||
void Game::demoHandlePlayerInput(const std::shared_ptr<Player> &player, int index) {
|
||||
const auto &demo_data = demo_.data[index][demo_.counter];
|
||||
|
||||
if (demo_data.left == 1) {
|
||||
@@ -1721,10 +1721,10 @@ void Game::playSound(const std::string &name) {
|
||||
|
||||
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||
void Game::movePlayersToFront() {
|
||||
if (players_to_reorder.empty())
|
||||
if (players_to_reorder_.empty())
|
||||
return;
|
||||
|
||||
for (auto &player : players_to_reorder) {
|
||||
for (auto &player : players_to_reorder_) {
|
||||
auto it = std::find(players_.begin(), players_.end(), player);
|
||||
if (it != players_.end() && it != players_.begin()) {
|
||||
std::shared_ptr<Player> dying_player = *it;
|
||||
@@ -1732,7 +1732,7 @@ void Game::movePlayersToFront() {
|
||||
players_.insert(players_.begin(), dying_player);
|
||||
}
|
||||
}
|
||||
players_to_reorder.clear();
|
||||
players_to_reorder_.clear();
|
||||
}
|
||||
|
||||
// Comprueba si está activo el menu de servicio para poner el juego en pausa
|
||||
|
||||
@@ -39,13 +39,13 @@ constexpr int TOTAL_SCORE_DATA = 3;
|
||||
class Game {
|
||||
public:
|
||||
// Constructor
|
||||
Game(int playerID, int current_stage, bool demo);
|
||||
Game(int player_id, int current_stage, bool demo);
|
||||
|
||||
// Destructor
|
||||
~Game();
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
// Bucle principal del juego
|
||||
void run();
|
||||
// Bucle principal del juego
|
||||
void run();
|
||||
|
||||
private:
|
||||
// --- Tipos internos ---
|
||||
@@ -59,18 +59,18 @@ class Game {
|
||||
};
|
||||
|
||||
// --- Constantes internas ---
|
||||
static constexpr int HELP_COUNTER_ = 1000;
|
||||
static constexpr int GAME_COMPLETED_START_FADE_ = 500;
|
||||
static constexpr int GAME_COMPLETED_END_ = 700;
|
||||
static constexpr int GAME_OVER_COUNTER_ = 350;
|
||||
static constexpr int TIME_STOPPED_COUNTER_ = 360;
|
||||
static constexpr int ITEM_POINTS_1_DISK_ODDS_ = 10;
|
||||
static constexpr int ITEM_POINTS_2_GAVINA_ODDS_ = 6;
|
||||
static constexpr int ITEM_POINTS_3_PACMAR_ODDS_ = 3;
|
||||
static constexpr int ITEM_CLOCK_ODDS_ = 5;
|
||||
static constexpr int ITEM_COFFEE_ODDS_ = 5;
|
||||
static constexpr int ITEM_POWER_BALL_ODDS_ = 0;
|
||||
static constexpr int ITEM_COFFEE_MACHINE_ODDS_ = 4;
|
||||
static constexpr int HELP_COUNTER = 1000;
|
||||
static constexpr int GAME_COMPLETED_START_FADE = 500;
|
||||
static constexpr int GAME_COMPLETED_END = 700;
|
||||
static constexpr int GAME_OVER_COUNTER = 350;
|
||||
static constexpr int TIME_STOPPED_COUNTER = 360;
|
||||
static constexpr int ITEM_POINTS_1_DISK_ODDS = 10;
|
||||
static constexpr int ITEM_POINTS_2_GAVINA_ODDS = 6;
|
||||
static constexpr int ITEM_POINTS_3_PACMAR_ODDS = 3;
|
||||
static constexpr int ITEM_CLOCK_ODDS = 5;
|
||||
static constexpr int ITEM_COFFEE_ODDS = 5;
|
||||
static constexpr int ITEM_POWER_BALL_ODDS = 0;
|
||||
static constexpr int ITEM_COFFEE_MACHINE_ODDS = 4;
|
||||
|
||||
// --- Estructuras ---
|
||||
struct Helper {
|
||||
@@ -89,13 +89,13 @@ class Game {
|
||||
: need_coffee(false),
|
||||
need_coffee_machine(false),
|
||||
need_power_ball(false),
|
||||
counter(HELP_COUNTER_),
|
||||
item_disk_odds(ITEM_POINTS_1_DISK_ODDS_),
|
||||
item_gavina_odds(ITEM_POINTS_2_GAVINA_ODDS_),
|
||||
item_pacmar_odds(ITEM_POINTS_3_PACMAR_ODDS_),
|
||||
item_clock_odds(ITEM_CLOCK_ODDS_),
|
||||
item_coffee_odds(ITEM_COFFEE_ODDS_),
|
||||
item_coffee_machine_odds(ITEM_COFFEE_MACHINE_ODDS_) {}
|
||||
counter(HELP_COUNTER),
|
||||
item_disk_odds(ITEM_POINTS_1_DISK_ODDS),
|
||||
item_gavina_odds(ITEM_POINTS_2_GAVINA_ODDS),
|
||||
item_pacmar_odds(ITEM_POINTS_3_PACMAR_ODDS),
|
||||
item_clock_odds(ITEM_CLOCK_ODDS),
|
||||
item_coffee_odds(ITEM_COFFEE_ODDS),
|
||||
item_coffee_machine_odds(ITEM_COFFEE_MACHINE_ODDS) {}
|
||||
};
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
@@ -144,13 +144,13 @@ class Game {
|
||||
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
|
||||
int counter_ = 0; // Contador para el juego
|
||||
int game_completed_counter_ = 0; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos
|
||||
int game_over_counter_ = GAME_OVER_COUNTER_; // Contador para el estado de fin de partida
|
||||
int game_over_counter_ = GAME_OVER_COUNTER; // Contador para el estado de fin de partida
|
||||
int time_stopped_counter_ = 0; // Temporizador para llevar la cuenta del tiempo detenido
|
||||
int total_power_to_complete_game_; // La suma del poder necesario para completar todas las fases
|
||||
int menace_current_ = 0; // Nivel de amenaza actual
|
||||
int menace_threshold_ = 0; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el número de globos
|
||||
GameState state_ = GameState::FADE_IN; // Estado
|
||||
std::vector<std::shared_ptr<Player>> players_to_reorder;
|
||||
std::vector<std::shared_ptr<Player>> players_to_reorder_;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
||||
@@ -208,16 +208,16 @@ class Game {
|
||||
void checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index); // Saca del estado de GAME OVER al jugador si el otro está activo
|
||||
void checkPlayersStatusPlaying(); // Comprueba el estado de juego de los jugadores
|
||||
std::shared_ptr<Player> getPlayer(int id); // Obtiene un jugador a partir de su "id"
|
||||
int getController(int playerId); // Obtiene un controlador a partir del "id" del jugador
|
||||
int getController(int player_id); // Obtiene un controlador a partir del "id" del jugador
|
||||
void checkInput(); // Gestiona la entrada durante el juego
|
||||
void checkPauseInput(); // Verifica si alguno de los controladores ha solicitado una pausa y actualiza el estado de pausa del juego.
|
||||
void DEMO_handleInput(); // Gestiona las entradas de los jugadores en el modo demo, incluyendo movimientos y disparos automáticos.
|
||||
void DEMO_handlePassInput(); // Gestiona las entradas de los jugadores en el modo demo para saltarse la demo.
|
||||
void DEMO_handlePlayerInput(const std::shared_ptr<Player> &player, int index); // Procesa las entradas para un jugador específico durante el modo demo.
|
||||
void handleFireInput(const std::shared_ptr<Player> &player, BulletType bulletType); // Maneja el disparo de un jugador, incluyendo la creación de balas y la gestión del tiempo de espera entre disparos.
|
||||
void demoHandleInput(); // Gestiona las entradas de los jugadores en el modo demo, incluyendo movimientos y disparos automáticos.
|
||||
void demoHandlePassInput(); // Gestiona las entradas de los jugadores en el modo demo para saltarse la demo.
|
||||
void demoHandlePlayerInput(const std::shared_ptr<Player> &player, int index); // Procesa las entradas para un jugador específico durante el modo demo.
|
||||
void handleFireInput(const std::shared_ptr<Player> &player, BulletType bullet_type); // Maneja el disparo de un jugador, incluyendo la creación de balas y la gestión del tiempo de espera entre disparos.
|
||||
void handlePlayersInput(); // Gestiona las entradas de todos los jugadores en el modo normal (fuera del modo demo).
|
||||
void handleNormalPlayerInput(const std::shared_ptr<Player> &player); // Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||
void handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controllerIndex); // Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||
void handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controller_index); // Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||
void handlePlayerContinue(const std::shared_ptr<Player> &player); // Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||
void handleNameInput(const std::shared_ptr<Player> &player); // Procesa las entradas para la introducción del nombre del jugador.
|
||||
void initDemo(int player_id); // Inicializa las variables para el modo DEMO
|
||||
|
||||
@@ -383,7 +383,7 @@ void HiScoreTable::updateCounter() {
|
||||
background_->setAlpha(96);
|
||||
}
|
||||
|
||||
if (counter_ == COUNTER_END_) {
|
||||
if (counter_ == COUNTER_END) {
|
||||
fade_->activate();
|
||||
}
|
||||
}
|
||||
@@ -39,40 +39,40 @@ class HiScoreTable {
|
||||
|
||||
private:
|
||||
// --- Constantes ---
|
||||
static constexpr Uint16 COUNTER_END_ = 800; // Valor final para el contador
|
||||
static constexpr Uint16 COUNTER_END = 800; // Valor final para el contador
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
|
||||
// --- Objetos y punteros ---
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
|
||||
|
||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||
std::unique_ptr<Background> background_; // Objeto para dibujar el fondo del juego
|
||||
std::unique_ptr<Sprite> header_; // Sprite con la cabecera del texto
|
||||
std::vector<std::shared_ptr<PathSprite>> entry_names_; // Lista con los sprites de cada uno de los nombres de la tabla de records
|
||||
std::vector<Path> paths_; // Vector con los recorridos precalculados
|
||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||
std::unique_ptr<Background> background_; // Objeto para dibujar el fondo del juego
|
||||
std::unique_ptr<Sprite> header_; // Sprite con la cabecera del texto
|
||||
std::vector<std::shared_ptr<PathSprite>> entry_names_; // Lista con los sprites de cada uno de los nombres de la tabla de records
|
||||
std::vector<Path> paths_; // Vector con los recorridos precalculados
|
||||
|
||||
// --- Variables ---
|
||||
Uint16 counter_ = 0; // Contador
|
||||
Uint64 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||
SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla
|
||||
FadeMode fade_mode_; // Modo de fade a utilizar
|
||||
Color background_fade_color_; // Color de atenuación del fondo
|
||||
std::vector<Color> entry_colors_; // Colores para destacar las entradas en la tabla
|
||||
// --- Variables ---
|
||||
Uint16 counter_ = 0; // Contador
|
||||
Uint64 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||
SDL_FRect view_area_; // Parte de la textura que se muestra en pantalla
|
||||
FadeMode fade_mode_; // Modo de fade a utilizar
|
||||
Color background_fade_color_; // Color de atenuación del fondo
|
||||
std::vector<Color> entry_colors_; // Colores para destacar las entradas en la tabla
|
||||
|
||||
// --- Métodos internos ---
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Pinta en pantalla
|
||||
void checkEvents(); // Comprueba los eventos
|
||||
void checkInput(); // Comprueba las entradas
|
||||
std::string format(int number); // Convierte un entero a un string con separadores de miles
|
||||
void fillTexture(); // Dibuja los sprites en la textura
|
||||
void updateFade(); // Gestiona el fade
|
||||
void createSprites(); // Crea los sprites con los textos
|
||||
void updateSprites(); // Actualiza las posiciones de los sprites de texto
|
||||
void initFade(); // Inicializa el fade
|
||||
void initBackground(); // Inicializa el fondo
|
||||
Color getEntryColor(int counter_); // Obtiene un color del vector de colores de entradas
|
||||
void iniEntryColors(); // Inicializa los colores de las entradas
|
||||
void glowEntryNames(); // Hace brillar los nombres de la tabla de records
|
||||
void updateCounter(); // Gestiona el contador
|
||||
// --- Métodos internos ---
|
||||
void update(); // Actualiza las variables
|
||||
void render(); // Pinta en pantalla
|
||||
void checkEvents(); // Comprueba los eventos
|
||||
void checkInput(); // Comprueba las entradas
|
||||
std::string format(int number); // Convierte un entero a un string con separadores de miles
|
||||
void fillTexture(); // Dibuja los sprites en la textura
|
||||
void updateFade(); // Gestiona el fade
|
||||
void createSprites(); // Crea los sprites con los textos
|
||||
void updateSprites(); // Actualiza las posiciones de los sprites de texto
|
||||
void initFade(); // Inicializa el fade
|
||||
void initBackground(); // Inicializa el fondo
|
||||
Color getEntryColor(int counter); // Obtiene un color del vector de colores de entradas
|
||||
void iniEntryColors(); // Inicializa los colores de las entradas
|
||||
void glowEntryNames(); // Hace brillar los nombres de la tabla de records
|
||||
void updateCounter(); // Gestiona el contador
|
||||
};
|
||||
@@ -294,12 +294,12 @@ bool Instructions::moveLines(std::vector<Line> &lines, int width, float duration
|
||||
bool all_lines_off_screen = true;
|
||||
|
||||
for (auto &line : lines) {
|
||||
// Establecer startTime en el primer cuadro de animación
|
||||
if (line.startTime == 0) {
|
||||
line.startTime = current_time + line.y * start_delay;
|
||||
// Establecer start_time en el primer cuadro de animación
|
||||
if (line.start_time == 0) {
|
||||
line.start_time = current_time + line.y * start_delay;
|
||||
}
|
||||
|
||||
float elapsed_time = (current_time - line.startTime) / 1000.0f; // Convertir a segundos
|
||||
float elapsed_time = (current_time - line.start_time) / 1000.0f; // Convertir a segundos
|
||||
if (elapsed_time < 0) {
|
||||
all_lines_off_screen = false; // Si aún no se debe mover esta línea, no están todas fuera de pantalla
|
||||
continue;
|
||||
|
||||
@@ -29,11 +29,11 @@ struct Line {
|
||||
int y; // Coordenada Y de la línea
|
||||
float x; // Coordenada X inicial (usamos float para mayor precisión en el suavizado)
|
||||
int direction; // Dirección de movimiento: -1 para izquierda, 1 para derecha
|
||||
Uint32 startTime; // Tiempo de inicio del movimiento
|
||||
Uint32 start_time; // Tiempo de inicio del movimiento
|
||||
|
||||
// Constructor de Line
|
||||
Line(int y, float x, int direction)
|
||||
: y(y), x(x), direction(direction), startTime(0) {}
|
||||
: y(y), x(x), direction(direction), start_time(0) {}
|
||||
};
|
||||
|
||||
// Clase Instructions
|
||||
@@ -81,7 +81,7 @@ class Instructions {
|
||||
void iniSprites(); // Inicializa los sprites de los items
|
||||
void updateSprites(); // Actualiza los sprites
|
||||
std::vector<Line> initializeLines(int height); // Inicializa las líneas animadas
|
||||
bool moveLines(std::vector<Line> &lines, int width, float duration, Uint32 startDelay); // Mueve las líneas
|
||||
bool moveLines(std::vector<Line> &lines, int width, float duration, Uint32 start_delay); // Mueve las líneas
|
||||
void renderLines(SDL_Renderer *renderer, SDL_Texture *texture, const std::vector<Line> &lines); // Renderiza las líneas
|
||||
void updateBackbuffer(); // Gestiona la textura con los gráficos
|
||||
};
|
||||
@@ -408,11 +408,11 @@ void Title::updateStartPrompt() {
|
||||
}
|
||||
}
|
||||
|
||||
should_render_start_prompt = condition_met;
|
||||
should_render_start_prompt_ = condition_met;
|
||||
}
|
||||
|
||||
void Title::renderStartPrompt() {
|
||||
if (should_render_start_prompt) {
|
||||
if (should_render_start_prompt_) {
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW,
|
||||
param.game.game_area.center_x,
|
||||
param.title.press_start_position,
|
||||
|
||||
@@ -67,7 +67,7 @@ class Title {
|
||||
Section::Options selection_ = Section::Options::TITLE_TIME_OUT; // Opción elegida en el título
|
||||
int num_controllers_; // Número de mandos conectados
|
||||
TitleState state_; // Estado actual de la sección
|
||||
bool should_render_start_prompt = false; // Indica si se muestra o no el texto de PRESS START BUTTON TO PLAY
|
||||
bool should_render_start_prompt_ = false; // Indica si se muestra o no el texto de PRESS START BUTTON TO PLAY
|
||||
bool player1_start_pressed_ = false; // Indica si se ha pulsdo el boton de empezar a jugar para el jugador 1
|
||||
bool player2_start_pressed_ = false; // Indica si se ha pulsdo el boton de empezar a jugar para el jugador 2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user