clang-tidy

This commit is contained in:
2025-08-17 10:20:41 +02:00
parent b359a73d50
commit 8ddc5d94f1
73 changed files with 867 additions and 833 deletions

View File

@@ -170,7 +170,7 @@ void Credits::fillTextTexture() {
const int SPACE_POST_TITLE = 3 + text->getCharacterSize();
const int SPACE_PRE_TITLE = text->getCharacterSize() * 4;
const int TEXTS_HEIGHT = 1 * text->getCharacterSize() + 8 * SPACE_POST_TITLE + 3 * SPACE_PRE_TITLE;
const int TEXTS_HEIGHT = (1 * text->getCharacterSize()) + (8 * SPACE_POST_TITLE) + (3 * SPACE_PRE_TITLE);
const int POS_X = static_cast<int>(param.game.game_area.center_x);
credits_rect_dst_.h = credits_rect_src_.h = static_cast<float>(TEXTS_HEIGHT);
auto text_style = Text::Style(Text::CENTER | Text::SHADOW, NO_TEXT_COLOR, SHADOW_TEXT_COLOR);
@@ -213,11 +213,11 @@ void Credits::fillTextTexture() {
y += SPACE_PRE_TITLE;
mini_logo_rect_src_.y = static_cast<float>(y);
auto mini_logo_sprite = std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"));
mini_logo_sprite->setPosition(1 + POS_X - mini_logo_sprite->getWidth() / 2, 1 + y);
mini_logo_sprite->setPosition(1 + POS_X - (mini_logo_sprite->getWidth() / 2), 1 + y);
Resource::get()->getTexture("logo_jailgames_mini.png")->setColor(SHADOW_TEXT_COLOR.r, SHADOW_TEXT_COLOR.g, SHADOW_TEXT_COLOR.b);
mini_logo_sprite->render();
mini_logo_sprite->setPosition(POS_X - mini_logo_sprite->getWidth() / 2, y);
mini_logo_sprite->setPosition(POS_X - (mini_logo_sprite->getWidth() / 2), y);
Resource::get()->getTexture("logo_jailgames_mini.png")->setColor(255, 255, 255);
mini_logo_sprite->render();

View File

@@ -466,35 +466,35 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
switch (item->getType()) {
case ItemType::DISK: {
player->addScore(1000, Options::settings.hi_score_table.back().score);
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(0));
playSound("item_pickup.wav");
break;
}
case ItemType::GAVINA: {
player->addScore(2500, Options::settings.hi_score_table.back().score);
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(1));
playSound("item_pickup.wav");
break;
}
case ItemType::PACMAR: {
player->addScore(5000, Options::settings.hi_score_table.back().score);
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(2));
playSound("item_pickup.wav");
break;
}
case ItemType::DEBIAN: {
player->addScore(100000, Options::settings.hi_score_table.back().score);
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(6));
playSound("debian_pickup.wav");
break;
}
case ItemType::CLOCK: {
enableTimeStopItem();
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(5));
playSound("item_pickup.wav");
break;
@@ -502,11 +502,11 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
case ItemType::COFFEE: {
if (player->getCoffees() == 2) {
player->addScore(5000, Options::settings.hi_score_table.back().score);
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(2));
} else {
player->giveExtraHit();
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(4));
}
playSound("voice_coffee.wav");
@@ -515,7 +515,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player) {
case ItemType::COFFEE_MACHINE: {
player->setPowerUp();
coffee_machine_enabled_ = false;
const auto X = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
const auto X = item->getPosX() + ((item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2);
createItemText(X, game_text_textures_.at(3));
playSound("voice_power_up.wav");
break;
@@ -582,19 +582,18 @@ void Game::handleTabeHitEffects() {
// Maneja la colisión entre bala y globos
auto Game::checkBulletBalloonCollision(const std::shared_ptr<Bullet> &bullet) -> bool {
for (auto &balloon : balloon_manager_->getBalloons()) {
return std::ranges::any_of(balloon_manager_->getBalloons(), [this, &bullet](auto &balloon) {
if (!balloon->isEnabled() || balloon->isInvulnerable()) {
continue;
return false;
}
if (!checkCollision(balloon->getCollider(), bullet->getCollider())) {
continue;
return false;
}
processBalloonHit(bullet, balloon);
return true;
}
return false;
});
}
// Procesa el impacto en un globo
@@ -623,9 +622,9 @@ void Game::handleItemDrop(const std::shared_ptr<Balloon> &balloon, const std::sh
}
// Maneja la destrucción del globo y puntuación
void Game::handleBalloonDestruction(std::shared_ptr<Balloon> balloon, const std::shared_ptr<Player> &player) {
void Game::handleBalloonDestruction(const std::shared_ptr<Balloon> &balloon, const std::shared_ptr<Player> &player) {
if (player->isPlaying()) {
auto const SCORE = balloon_manager_->popBalloon(std::move(balloon)) * player->getScoreMultiplier() * difficulty_score_multiplier_;
auto const SCORE = balloon_manager_->popBalloon(balloon) * player->getScoreMultiplier() * difficulty_score_multiplier_;
player->addScore(SCORE, Options::settings.hi_score_table.back().score);
player->incScoreMultiplier();
}
@@ -874,7 +873,7 @@ void Game::handlePlayerCollision(std::shared_ptr<Player> &player, std::shared_pt
if (player->hasExtraHit()) {
// Lo pierde
player->removeExtraHit();
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
throwCoffee(player->getPosX() + (Player::getWidth() / 2), player->getPosY() + (Player::getHeight() / 2));
playSound("coffee_out.wav");
screen_->shake();
} else {
@@ -986,9 +985,9 @@ void Game::fillCanvas() {
// Dibuja los objetos
background_->render();
balloon_manager_->render();
renderSmartSprites(); // El cafe que sale cuando te golpean
renderSmartSprites(); // El cafe que sale cuando te golpean
renderItems();
tabe_->render();
renderBullets();
@@ -1033,7 +1032,7 @@ void Game::initPaths() {
const auto &texture = Resource::get()->getTexture("game_text_get_ready");
const auto W = texture->getWidth();
const int X0 = -W;
const int X1 = param.game.play_area.center_x - W / 2;
const int X1 = param.game.play_area.center_x - (W / 2);
const int X2 = param.game.play_area.rect.w;
const int Y = param.game.play_area.center_y;
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20);
@@ -1045,7 +1044,7 @@ void Game::initPaths() {
const auto &texture = Resource::get()->getTexture("game_text_last_stage");
const auto H = texture->getHeight();
const int Y0 = param.game.play_area.rect.h - H;
const int Y1 = param.game.play_area.center_y - H / 2;
const int Y1 = param.game.play_area.center_y - (H / 2);
const int Y2 = -H;
const int X = param.game.play_area.center_x;
paths_.emplace_back(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20);
@@ -1058,9 +1057,9 @@ void Game::initPaths() {
const auto W = texture->getWidth();
const auto H = texture->getHeight();
const int X0 = -W;
const int X1 = param.game.play_area.center_x - W / 2;
const int X1 = param.game.play_area.center_x - (W / 2);
const int X2 = param.game.play_area.rect.w;
const int Y = param.game.play_area.center_y - H / 2 - 20;
const int Y = param.game.play_area.center_y - (H / 2) - 20;
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
}
@@ -1071,9 +1070,9 @@ void Game::initPaths() {
const auto W = texture->getWidth();
const auto H = texture->getHeight();
const int X0 = param.game.play_area.rect.w;
const int X1 = param.game.play_area.center_x - W / 2;
const int X1 = param.game.play_area.center_x - (W / 2);
const int X2 = -W;
const int Y = param.game.play_area.center_y + H / 2 - 20;
const int Y = param.game.play_area.center_y + (H / 2) - 20;
paths_.emplace_back(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400);
paths_.emplace_back(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0);
}
@@ -1199,7 +1198,7 @@ void Game::checkPlayersStatusPlaying() {
// Obtiene un jugador a partir de su "id"
auto Game::getPlayer(Player::Id id) -> std::shared_ptr<Player> {
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto &player) { return player->getId() == id; });
auto it = std::ranges::find_if(players_, [id](const auto &player) { return player->getId() == id; });
if (it != players_.end()) {
return *it;
@@ -1304,7 +1303,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
switch (bullet_type) {
case BulletType::UP:
player->setInput(Input::Action::FIRE_CENTER);
bullet.x = 2 + player->getPosX() + (player->getWidth() - Bullet::WIDTH) / 2;
bullet.x = 2 + player->getPosX() + (Player::getWidth() - Bullet::WIDTH) / 2;
bullet.y = player->getPosY() - (Bullet::HEIGHT / 2);
break;
case BulletType::LEFT:
@@ -1314,7 +1313,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
break;
case BulletType::RIGHT:
player->setInput(Input::Action::FIRE_RIGHT);
bullet.x = player->getPosX() + player->getWidth() - (Bullet::WIDTH / 2);
bullet.x = player->getPosX() + Player::getWidth() - (Bullet::WIDTH / 2);
bullet.y = player->getPosY();
break;
default:
@@ -1835,9 +1834,9 @@ void Game::sortPlayersByZOrder() {
// Procesar jugadores que van al fondo (se dibujan primero)
if (!players_to_put_at_back_.empty()) {
for (auto &player : players_to_put_at_back_) {
auto it = std::find(players_.begin(), players_.end(), player);
auto it = std::ranges::find(players_, player);
if (it != players_.end() && it != players_.begin()) {
std::shared_ptr<Player> dying_player = *it;
const std::shared_ptr<Player> &dying_player = *it;
players_.erase(it);
players_.insert(players_.begin(), dying_player);
}
@@ -1848,9 +1847,9 @@ void Game::sortPlayersByZOrder() {
// Procesar jugadores que van al frente (se dibujan últimos)
if (!players_to_put_at_front_.empty()) {
for (auto &player : players_to_put_at_front_) {
auto it = std::find(players_.begin(), players_.end(), player);
auto it = std::ranges::find(players_, player);
if (it != players_.end() && it != players_.end() - 1) {
std::shared_ptr<Player> front_player = *it;
const std::shared_ptr<Player> &front_player = *it;
players_.erase(it);
players_.push_back(front_player);
}
@@ -1910,7 +1909,7 @@ void Game::handleDebugEvents(const SDL_Event &event) {
}
case SDLK_5: // 5.000
{
const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
const int X = players_.at(0)->getPosX() + ((Player::getWidth() - game_text_textures_[3]->getWidth()) / 2);
createItemText(X, game_text_textures_.at(2));
break;
}
@@ -1921,7 +1920,7 @@ void Game::handleDebugEvents(const SDL_Event &event) {
}
case SDLK_7: // 100.000
{
const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
const int X = players_.at(0)->getPosX() + ((Player::getWidth() - game_text_textures_[3]->getWidth()) / 2);
createItemText(X, game_text_textures_.at(6));
break;
}

View File

@@ -253,9 +253,9 @@ class Game {
void createMessage(const std::vector<Path> &paths, const std::shared_ptr<Texture> &texture); // Crea mensaje con animación por ruta
// --- Sistema de globos y enemigos ---
void handleBalloonDestruction(std::shared_ptr<Balloon> balloon, const std::shared_ptr<Player> &player); // Procesa destrucción de globo
void handleTabeHitEffects(); // Gestiona efectos al golpear a Tabe
void checkAndUpdateBalloonSpeed(); // Ajusta velocidad de globos según progreso
void handleBalloonDestruction(const std::shared_ptr<Balloon> &balloon, const std::shared_ptr<Player> &player); // Procesa destrucción de globo
void handleTabeHitEffects(); // Gestiona efectos al golpear a Tabe
void checkAndUpdateBalloonSpeed(); // Ajusta velocidad de globos según progreso
// --- Gestión de fases y progresión ---
void updateStage(); // Verifica y actualiza cambio de fase

View File

@@ -177,11 +177,11 @@ void HiScoreTable::createSprites() {
float backbuffer_height;
SDL_GetTextureSize(backbuffer_, &backbuffer_width, &backbuffer_height);
constexpr int ENTRY_LENGHT = 22;
constexpr int ENTRY_LENGTH = 22;
constexpr int MAX_NAMES = 10;
const int SPACE_BETWEEN_HEADER = entry_text->getCharacterSize() * 4;
const int SPACE_BETWEEN_LINES = entry_text->getCharacterSize() * 2;
const int SIZE = SPACE_BETWEEN_HEADER + SPACE_BETWEEN_LINES * (MAX_NAMES - 1) + entry_text->getCharacterSize();
const int SIZE = SPACE_BETWEEN_HEADER + (SPACE_BETWEEN_LINES * (MAX_NAMES - 1)) + entry_text->getCharacterSize();
const int FIRST_LINE = (param.game.height - SIZE) / 2;
// Crea el sprite para el texto de cabecera
@@ -190,13 +190,13 @@ void HiScoreTable::createSprites() {
// Crea los sprites para las entradas en la tabla de puntuaciones
const int ANIMATION = rand() % 4;
const std::string SAMPLE_LINE(ENTRY_LENGHT + 3, ' ');
const std::string SAMPLE_LINE(ENTRY_LENGTH + 3, ' ');
auto sample_entry = std::make_unique<Sprite>(entry_text->writeDXToTexture(Text::SHADOW, SAMPLE_LINE, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR));
const auto ENTRY_WIDTH = sample_entry->getWidth();
for (int i = 0; i < MAX_NAMES; ++i) {
const auto TABLE_POSITION = format(i + 1) + ". ";
const auto SCORE = format(Options::settings.hi_score_table.at(i).score);
const auto NUM_DOTS = ENTRY_LENGHT - Options::settings.hi_score_table.at(i).name.size() - SCORE.size();
const auto NUM_DOTS = ENTRY_LENGTH - Options::settings.hi_score_table.at(i).name.size() - SCORE.size();
const auto *const ONE_CC = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : "";
std::string dots;
for (int j = 0; j < (int)NUM_DOTS; ++j) {
@@ -322,7 +322,7 @@ void HiScoreTable::initBackground() {
// Obtiene un color del vector de colores de entradas
auto HiScoreTable::getEntryColor(int counter) -> Color {
int cycle_length = entry_colors_.size() * 2 - 2;
int cycle_length = (entry_colors_.size() * 2) - 2;
size_t n = counter % cycle_length;
size_t index;

View File

@@ -137,7 +137,7 @@ void Instructions::fillTexture() {
const int FIRST_LINE = (param.game.height - SIZE) / 2;
// Calcula cual es el texto más largo de las descripciones de los items
int lenght = 0;
int length = 0;
const std::array<std::string, 5> ITEM_DESCRIPTIONS = {
Lang::getText("[INSTRUCTIONS] 07"),
Lang::getText("[INSTRUCTIONS] 08"),
@@ -146,9 +146,9 @@ void Instructions::fillTexture() {
Lang::getText("[INSTRUCTIONS] 11")};
for (const auto &desc : ITEM_DESCRIPTIONS) {
const int L = text_->length(desc);
lenght = L > lenght ? L : lenght;
length = L > length ? L : length;
}
const int ANCHOR_ITEM = (param.game.width - (lenght + X_OFFSET)) / 2;
const int ANCHOR_ITEM = (param.game.width - (length + X_OFFSET)) / 2;
auto caption_style = Text::Style(Text::CENTER | Text::COLOR | Text::SHADOW, ORANGE_TEXT_COLOR, SHADOW_TEXT_COLOR);
auto text_style = Text::Style(Text::CENTER | Text::COLOR | Text::SHADOW, NO_TEXT_COLOR, SHADOW_TEXT_COLOR);
@@ -157,21 +157,21 @@ void Instructions::fillTexture() {
text_->writeStyle(param.game.game_area.center_x, FIRST_LINE, Lang::getText("[INSTRUCTIONS] 01"), caption_style);
const int ANCHOR1 = FIRST_LINE + SPACE_POST_HEADER;
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 0, Lang::getText("[INSTRUCTIONS] 02"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 1, Lang::getText("[INSTRUCTIONS] 03"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 2, Lang::getText("[INSTRUCTIONS] 04"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3, Lang::getText("[INSTRUCTIONS] 05"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + (SPACE_BETWEEN_LINES * 0), Lang::getText("[INSTRUCTIONS] 02"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + (SPACE_BETWEEN_LINES * 1), Lang::getText("[INSTRUCTIONS] 03"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + (SPACE_BETWEEN_LINES * 2), Lang::getText("[INSTRUCTIONS] 04"), text_style);
text_->writeStyle(param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + (SPACE_BETWEEN_LINES * 3), Lang::getText("[INSTRUCTIONS] 05"), text_style);
// Escribe el texto de los objetos y sus puntos
const int ANCHOR2 = ANCHOR1 + SPACE_PRE_HEADER + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3;
const int ANCHOR2 = ANCHOR1 + SPACE_PRE_HEADER + SPACE_NEW_PARAGRAPH + (SPACE_BETWEEN_LINES * 3);
text_->writeStyle(param.game.game_area.center_x, ANCHOR2, Lang::getText("[INSTRUCTIONS] 06"), caption_style);
const int ANCHOR3 = ANCHOR2 + SPACE_POST_HEADER;
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + (SPACE_BETWEEN_ITEM_LINES * 0), Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + (SPACE_BETWEEN_ITEM_LINES * 1), Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + (SPACE_BETWEEN_ITEM_LINES * 2), Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + (SPACE_BETWEEN_ITEM_LINES * 3), Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + (SPACE_BETWEEN_ITEM_LINES * 4), Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
// Deja el renderizador como estaba
SDL_SetRenderTarget(renderer_, temp);

View File

@@ -326,7 +326,7 @@ void Intro::initSprites() {
card_sprites_.push_back(std::move(sprite));
}
const float X_DEST = param.game.game_area.center_x - CARD_WIDTH / 2;
const float X_DEST = param.game.game_area.center_x - (CARD_WIDTH / 2);
const float Y_DEST = param.game.game_area.first_quarter_y - (CARD_HEIGHT / 4);
card_sprites_.at(0)->addPath(-CARD_WIDTH - 10, X_DEST, PathType::HORIZONTAL, Y_DEST, 100, easeInOutExpo, 0);

View File

@@ -47,7 +47,7 @@ Title::Title()
// Configura objetos
tiled_bg_->setColor(param.title.bg_color);
game_logo_->enable();
mini_logo_sprite_->setX(param.game.game_area.center_x - mini_logo_sprite_->getWidth() / 2);
mini_logo_sprite_->setX(param.game.game_area.center_x - (mini_logo_sprite_->getWidth() / 2));
fade_->setColor(param.fade.color);
fade_->setType(Fade::Type::RANDOM_SQUARE);
fade_->setPostDuration(param.fade.post_duration);
@@ -560,7 +560,7 @@ void Title::renderPlayers() {
// Obtiene un jugador a partir de su "id"
auto Title::getPlayer(Player::Id id) -> std::shared_ptr<Player> {
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto& player) { return player->getId() == id; });
auto it = std::ranges::find_if(players_, [id](const auto& player) { return player->getId() == id; });
if (it != players_.end()) {
return *it;

View File

@@ -21,7 +21,7 @@ struct Gamepad;
// --- Constantes ---
constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner"; // Texto de copyright
constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false; // Permite saltar la animación del título
constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false; // Permite saltar la animación del título
// --- Clase Title: gestiona el estado de título/menú principal del juego ---
class Title {
@@ -63,9 +63,9 @@ class Title {
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad
int counter_ = 0; // Temporizador para la pantalla de título
int num_controllers_; // Número de mandos conectados
bool should_render_start_prompt_ = false; // Indica si se muestra el texto de PRESS START BUTTON TO PLAY
bool player1_start_pressed_ = false; // Indica si se ha pulsado el botón de empezar para el jugador 1
bool player2_start_pressed_ = false; // Indica si se ha pulsado el botón de empezar para el jugador 2
bool should_render_start_prompt_ = false; // Indica si se muestra el texto de PRESS START BUTTON TO PLAY
bool player1_start_pressed_ = false; // Indica si se ha pulsado el botón de empezar para el jugador 1
bool player2_start_pressed_ = false; // Indica si se ha pulsado el botón de empezar para el jugador 2
// --- Ciclo de vida del título ---
void update(); // Actualiza las variables del objeto