clang-tidy (amb el fuck de que no feien bona parella el clang de macos i el tidy de llvm)
This commit is contained in:
@@ -223,7 +223,7 @@ void Credits::fillTextTexture() {
|
||||
mini_logo_rect_dst_.h = mini_logo_rect_src_.h = mini_logo_sprite->getHeight() + 3 + text->getCharacterSize();
|
||||
credits_rect_dst_.y = param.game.game_area.rect.h;
|
||||
mini_logo_rect_dst_.y = credits_rect_dst_.y + credits_rect_dst_.h + 30;
|
||||
mini_logo_final_pos_ = param.game.game_area.center_y - mini_logo_rect_src_.h / 2;
|
||||
mini_logo_final_pos_ = param.game.game_area.center_y - (mini_logo_rect_src_.h / 2);
|
||||
}
|
||||
|
||||
// Dibuja todos los sprites en la textura
|
||||
|
||||
@@ -107,32 +107,32 @@ class Credits {
|
||||
|
||||
// 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};
|
||||
.x = param.game.game_area.rect.x,
|
||||
.y = param.game.game_area.rect.y + black_bars_size_,
|
||||
.w = param.game.game_area.rect.w,
|
||||
.h = 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_};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.rect.y,
|
||||
.w = play_area_.w,
|
||||
.h = 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_};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.rect.h - black_bars_size_,
|
||||
.w = play_area_.w,
|
||||
.h = black_bars_size_};
|
||||
SDL_FRect left_black_rect_ = {
|
||||
play_area_.x,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
.x = play_area_.x,
|
||||
.y = param.game.game_area.center_y - 1,
|
||||
.w = 0,
|
||||
.h = 2};
|
||||
SDL_FRect right_black_rect_ = {
|
||||
play_area_.x + play_area_.w,
|
||||
param.game.game_area.center_y - 1,
|
||||
0,
|
||||
2};
|
||||
.x = play_area_.x + play_area_.w,
|
||||
.y = param.game.game_area.center_y - 1,
|
||||
.w = 0,
|
||||
.h = 2};
|
||||
|
||||
// Borde para la ventana
|
||||
SDL_FRect border_rect_ = play_area_; // Delimitador de ventana
|
||||
|
||||
@@ -57,7 +57,7 @@ Game::Game(Player::Id player_id, int current_stage, bool demo_enabled)
|
||||
screen_(Screen::get()),
|
||||
input_(Input::get()),
|
||||
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
||||
pause_manager_(std::make_unique<PauseManager>([this](bool is_paused) { onPauseStateChanged(is_paused); })),
|
||||
pause_manager_(std::make_unique<PauseManager>([this](bool is_paused) -> void { onPauseStateChanged(is_paused); })),
|
||||
stage_manager_(std::make_unique<StageManager>()),
|
||||
balloon_manager_(std::make_unique<BalloonManager>(stage_manager_.get())),
|
||||
bullet_manager_(std::make_unique<BulletManager>()),
|
||||
@@ -71,8 +71,8 @@ Game::Game(Player::Id player_id, int current_stage, bool demo_enabled)
|
||||
// Otras variables
|
||||
Section::name = Section::Name::GAME;
|
||||
Section::options = Section::Options::NONE;
|
||||
stage_manager_->initialize(Asset::get()->get("stages.txt"));
|
||||
stage_manager_->setPowerChangeCallback([this](int amount) { background_->incrementProgress(amount); });
|
||||
stage_manager_->initialize(Asset::get()->getPath("stages.txt"));
|
||||
stage_manager_->setPowerChangeCallback([this](int amount) -> void { background_->incrementProgress(amount); });
|
||||
stage_manager_->jumpToStage(current_stage);
|
||||
|
||||
// Asigna texturas y animaciones
|
||||
@@ -109,7 +109,7 @@ Game::Game(Player::Id player_id, int current_stage, bool demo_enabled)
|
||||
initPaths();
|
||||
|
||||
// Registra callbacks
|
||||
ServiceMenu::get()->setStateChangeCallback([this](bool is_active) {
|
||||
ServiceMenu::get()->setStateChangeCallback([this](bool is_active) -> void {
|
||||
// Solo aplicar pausa si NO estamos en modo demo
|
||||
if (!demo_.enabled) {
|
||||
pause_manager_->setServiceMenuPause(is_active);
|
||||
@@ -117,15 +117,15 @@ Game::Game(Player::Id player_id, int current_stage, bool demo_enabled)
|
||||
});
|
||||
|
||||
// Configura callbacks del BulletManager
|
||||
bullet_manager_->setTabeCollisionCallback([this](const std::shared_ptr<Bullet>& bullet) {
|
||||
bullet_manager_->setTabeCollisionCallback([this](const std::shared_ptr<Bullet>& bullet) -> bool {
|
||||
return checkBulletTabeCollision(bullet);
|
||||
});
|
||||
|
||||
bullet_manager_->setBalloonCollisionCallback([this](const std::shared_ptr<Bullet>& bullet) {
|
||||
bullet_manager_->setBalloonCollisionCallback([this](const std::shared_ptr<Bullet>& bullet) -> bool {
|
||||
return checkBulletBalloonCollision(bullet);
|
||||
});
|
||||
|
||||
bullet_manager_->setOutOfBoundsCallback([this](const std::shared_ptr<Bullet>& bullet) {
|
||||
bullet_manager_->setOutOfBoundsCallback([this](const std::shared_ptr<Bullet>& bullet) -> void {
|
||||
getPlayer(static_cast<Player::Id>(bullet->getOwner()))->decScoreMultiplier();
|
||||
});
|
||||
#ifdef RECORDING
|
||||
@@ -137,7 +137,7 @@ Game::~Game() {
|
||||
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
|
||||
if (!demo_.enabled) {
|
||||
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
||||
manager->saveToFile(Asset::get()->get("score.bin"));
|
||||
manager->saveToFile(Asset::get()->getPath("score.bin"));
|
||||
Section::attract_mode = Section::AttractMode::TITLE_TO_DEMO;
|
||||
if (Options::audio.enabled) {
|
||||
// Musica
|
||||
@@ -151,7 +151,7 @@ Game::~Game() {
|
||||
ServiceMenu::get()->setStateChangeCallback(nullptr);
|
||||
|
||||
#ifdef RECORDING
|
||||
saveDemoFile(Asset::get()->get("demo1.bin"), demo_.data.at(0));
|
||||
saveDemoFile(Asset::get()->getPath("demo1.bin"), demo_.data.at(0));
|
||||
#endif
|
||||
|
||||
Scoreboard::destroy();
|
||||
@@ -551,7 +551,7 @@ void Game::handleTabeHitEffects() {
|
||||
|
||||
// Maneja la colisión entre bala y globos
|
||||
auto Game::checkBulletBalloonCollision(const std::shared_ptr<Bullet>& bullet) -> bool {
|
||||
return std::ranges::any_of(balloon_manager_->getBalloons(), [this, &bullet](auto& balloon) {
|
||||
return std::ranges::any_of(balloon_manager_->getBalloons(), [this, &bullet](auto& balloon) -> auto {
|
||||
if (!balloon->isEnabled() || balloon->isInvulnerable()) {
|
||||
return false;
|
||||
}
|
||||
@@ -684,7 +684,7 @@ void Game::createItem(ItemType type, float x, float y) {
|
||||
|
||||
// Vacia el vector de items
|
||||
void Game::freeItems() {
|
||||
std::erase_if(items_, [&](const auto& item) {
|
||||
std::erase_if(items_, [&](const auto& item) -> auto {
|
||||
if (!item->isEnabled()) {
|
||||
// Comprobamos si hay que realizar una acción extra
|
||||
if (item->getType() == ItemType::COFFEE_MACHINE) {
|
||||
@@ -715,7 +715,7 @@ void Game::createItemText(int x, const std::shared_ptr<Texture>& texture) {
|
||||
// Inicializa
|
||||
path_sprites_.back()->setWidth(W);
|
||||
path_sprites_.back()->setHeight(H);
|
||||
path_sprites_.back()->setSpriteClip({0, 0, static_cast<float>(W), static_cast<float>(H)});
|
||||
path_sprites_.back()->setSpriteClip({.x = 0, .y = 0, .w = static_cast<float>(W), .h = static_cast<float>(H)});
|
||||
path_sprites_.back()->addPath(Y0, Y1, PathType::VERTICAL, x, 1.667F, easeOutQuint, 0); // 100 frames → 1.667s
|
||||
path_sprites_.back()->addPath(Y1, Y2, PathType::VERTICAL, x, 1.333F, easeInQuint, 0); // 80 frames → 1.333s
|
||||
path_sprites_.back()->enable();
|
||||
@@ -734,14 +734,14 @@ void Game::createMessage(const std::vector<Path>& paths, const std::shared_ptr<T
|
||||
|
||||
// Vacia la lista de smartsprites
|
||||
void Game::freeSmartSprites() {
|
||||
std::erase_if(smart_sprites_, [](const auto& sprite) {
|
||||
std::erase_if(smart_sprites_, [](const auto& sprite) -> auto {
|
||||
return sprite->hasFinished();
|
||||
});
|
||||
}
|
||||
|
||||
// Vacia la lista de pathsprites
|
||||
void Game::freePathSprites() {
|
||||
std::erase_if(path_sprites_, [](const auto& sprite) {
|
||||
std::erase_if(path_sprites_, [](const auto& sprite) -> auto {
|
||||
return sprite->hasFinished();
|
||||
});
|
||||
}
|
||||
@@ -763,7 +763,7 @@ void Game::throwCoffee(int x, int y) {
|
||||
smart_sprites_.back()->setEnabled(true);
|
||||
smart_sprites_.back()->setFinishedDelay(0.0F);
|
||||
smart_sprites_.back()->setSpriteClip(0, Item::HEIGHT, Item::WIDTH, Item::HEIGHT);
|
||||
smart_sprites_.back()->setRotatingCenter({Item::WIDTH / 2, Item::HEIGHT / 2});
|
||||
smart_sprites_.back()->setRotatingCenter({.x = Item::WIDTH / 2, .y = Item::HEIGHT / 2});
|
||||
smart_sprites_.back()->setRotate(true);
|
||||
smart_sprites_.back()->setRotateAmount(90.0);
|
||||
}
|
||||
@@ -1200,7 +1200,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::ranges::find_if(players_, [id](const auto& player) { return player->getId() == id; });
|
||||
auto it = std::ranges::find_if(players_, [id](const auto& player) -> auto { return player->getId() == id; });
|
||||
|
||||
if (it != players_.end()) {
|
||||
return *it;
|
||||
@@ -1298,11 +1298,11 @@ void Game::demoHandlePlayerInput(const std::shared_ptr<Player>& player, int inde
|
||||
// Maneja el disparo de un jugador, incluyendo la creación de balas y la gestión del tiempo de espera entre disparos.
|
||||
void Game::handleFireInput(const std::shared_ptr<Player>& player, Bullet::Type type) {
|
||||
if (player->canFire()) {
|
||||
SDL_Point bullet = {0, 0};
|
||||
SDL_Point bullet = {.x = 0, .y = 0};
|
||||
switch (type) {
|
||||
case Bullet::Type::UP:
|
||||
player->setInput(Input::Action::FIRE_CENTER);
|
||||
bullet.x = 2 + player->getPosX() + (Player::WIDTH - Bullet::WIDTH) / 2;
|
||||
bullet.x = 2 + player->getPosX() + ((Player::WIDTH - Bullet::WIDTH) / 2);
|
||||
bullet.y = player->getPosY() - (Bullet::HEIGHT / 2);
|
||||
break;
|
||||
case Bullet::Type::LEFT:
|
||||
@@ -1969,7 +1969,7 @@ void Game::buildPlayerDrawList(const Players& elements, Players& draw_list) {
|
||||
for (const auto& e : elements) {
|
||||
draw_list.push_back(e); // copia el shared_ptr
|
||||
}
|
||||
std::ranges::stable_sort(draw_list, [](const std::shared_ptr<Player>& a, const std::shared_ptr<Player>& b) {
|
||||
std::ranges::stable_sort(draw_list, [](const std::shared_ptr<Player>& a, const std::shared_ptr<Player>& b) -> bool {
|
||||
return a->getZOrder() < b->getZOrder();
|
||||
});
|
||||
}
|
||||
@@ -1983,7 +1983,7 @@ void Game::updatePlayerDrawList(const Players& elements, Players& draw_list) {
|
||||
return;
|
||||
}
|
||||
// Dado que apuntan a los mismos elementos, basta ordenar por los z_order actuales.
|
||||
std::ranges::stable_sort(draw_list, [](const std::shared_ptr<Player>& a, const std::shared_ptr<Player>& b) {
|
||||
std::ranges::stable_sort(draw_list, [](const std::shared_ptr<Player>& a, const std::shared_ptr<Player>& b) -> bool {
|
||||
return a->getZOrder() < b->getZOrder();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,22 +96,13 @@ class Game {
|
||||
bool need_coffee{false}; // Indica si se necesitan cafes
|
||||
bool need_coffee_machine{false}; // Indica si se necesita PowerUp
|
||||
bool need_power_ball{false}; // Indica si se necesita una PowerBall
|
||||
float counter; // Contador para no dar ayudas consecutivas
|
||||
int item_disk_odds; // Probabilidad de aparición del objeto
|
||||
int item_gavina_odds; // Probabilidad de aparición del objeto
|
||||
int item_pacmar_odds; // Probabilidad de aparición del objeto
|
||||
int item_clock_odds; // Probabilidad de aparición del objeto
|
||||
int item_coffee_odds; // Probabilidad de aparición del objeto
|
||||
int item_coffee_machine_odds; // Probabilidad de aparición del objeto
|
||||
|
||||
Helper()
|
||||
: counter(HELP_COUNTER_S * 1000), // Convertir a milisegundos para compatibilidad
|
||||
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) {}
|
||||
float counter{HELP_COUNTER_S * 1000}; // Contador para no dar ayudas consecutivas
|
||||
int item_disk_odds{ITEM_POINTS_1_DISK_ODDS}; // Probabilidad de aparición del objeto
|
||||
int item_gavina_odds{ITEM_POINTS_2_GAVINA_ODDS}; // Probabilidad de aparición del objeto
|
||||
int item_pacmar_odds{ITEM_POINTS_3_PACMAR_ODDS}; // Probabilidad de aparición del objeto
|
||||
int item_clock_odds{ITEM_CLOCK_ODDS}; // Probabilidad de aparición del objeto
|
||||
int item_coffee_odds{ITEM_COFFEE_ODDS}; // Probabilidad de aparición del objeto
|
||||
int item_coffee_machine_odds{ITEM_COFFEE_MACHINE_ODDS}; // Probabilidad de aparición del objeto
|
||||
};
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <algorithm> // Para max
|
||||
#include <cstdlib> // Para rand, size_t
|
||||
#include <functional> // Para function
|
||||
#include <utility> // Para std::cmp_less
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "audio.hpp" // Para Audio
|
||||
@@ -34,7 +35,7 @@ HiScoreTable::HiScoreTable()
|
||||
fade_(std::make_unique<Fade>()),
|
||||
background_(std::make_unique<Background>()),
|
||||
|
||||
view_area_(SDL_FRect{0, 0, param.game.width, param.game.height}),
|
||||
view_area_(SDL_FRect{.x = 0, .y = 0, .w = param.game.width, .h = param.game.height}),
|
||||
fade_mode_(Fade::Mode::IN),
|
||||
background_fade_color_(Color(0, 0, 0)) {
|
||||
// Inicializa el resto
|
||||
@@ -145,7 +146,7 @@ void HiScoreTable::updateFade(float delta_time) {
|
||||
fade_->update(delta_time);
|
||||
|
||||
if (fade_->hasEnded() && fade_mode_ == Fade::Mode::IN) {
|
||||
fade_->reset();
|
||||
(*fade_).reset();
|
||||
fade_mode_ = Fade::Mode::OUT;
|
||||
fade_->setMode(fade_mode_);
|
||||
}
|
||||
@@ -163,7 +164,7 @@ auto HiScoreTable::format(int number) -> std::string {
|
||||
const std::string SEPARATOR = ".";
|
||||
const std::string SCORE = std::to_string(number);
|
||||
|
||||
auto index = (int)SCORE.size() - 1;
|
||||
auto index = static_cast<int>(SCORE.size()) - 1;
|
||||
std::string result;
|
||||
auto i = 0;
|
||||
while (index >= 0) {
|
||||
@@ -211,7 +212,7 @@ void HiScoreTable::createSprites() {
|
||||
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) {
|
||||
for (int j = 0; std::cmp_less(j, NUM_DOTS); ++j) {
|
||||
dots = dots + ".";
|
||||
}
|
||||
const auto LINE = TABLE_POSITION + Options::settings.hi_score_table.at(i).name + dots + SCORE + ONE_CC;
|
||||
@@ -264,7 +265,7 @@ void HiScoreTable::updateSprites(float delta_time) {
|
||||
if (elapsed_time_ >= INIT_DELAY_S) {
|
||||
const float ELAPSED_SINCE_INIT = elapsed_time_ - INIT_DELAY_S;
|
||||
int index = static_cast<int>(ELAPSED_SINCE_INIT / ENTRY_DELAY_S);
|
||||
if (index < static_cast<int>(entry_names_.size()) && index >= 0) {
|
||||
if (std::cmp_less(index, entry_names_.size()) && index >= 0) {
|
||||
// Verificar si este índice debe activarse ahora
|
||||
float expected_time = index * ENTRY_DELAY_S;
|
||||
if (ELAPSED_SINCE_INIT >= expected_time && ELAPSED_SINCE_INIT < expected_time + delta_time) {
|
||||
@@ -340,7 +341,7 @@ auto HiScoreTable::getEntryColor(int counter) -> Color {
|
||||
if (n < entry_colors_.size()) {
|
||||
index = n; // Avanza: 0,1,2,3
|
||||
} else {
|
||||
index = 2 * (entry_colors_.size() - 1) - n; // Retrocede: 2,1
|
||||
index = (2 * (entry_colors_.size() - 1)) - n; // Retrocede: 2,1
|
||||
}
|
||||
|
||||
return entry_colors_[index];
|
||||
|
||||
@@ -78,16 +78,16 @@ void Instructions::iniSprites() {
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee.png"));
|
||||
|
||||
// Inicializa los sprites
|
||||
for (int i = 0; i < (int)item_textures_.size(); ++i) {
|
||||
for (int i = 0; std::cmp_less(i, item_textures_.size()); ++i) {
|
||||
auto sprite = std::make_unique<Sprite>(item_textures_[i], 0, 0, Item::WIDTH, Item::HEIGHT);
|
||||
sprite->setPosition((SDL_FPoint){sprite_pos_.x, sprite_pos_.y + ((Item::HEIGHT + item_space_) * i)});
|
||||
sprite->setPosition((SDL_FPoint){.x = sprite_pos_.x, .y = sprite_pos_.y + ((Item::HEIGHT + item_space_) * i)});
|
||||
sprites_.push_back(std::move(sprite));
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los sprites
|
||||
void Instructions::updateSprites() {
|
||||
SDL_FRect src_rect = {0, 0, Item::WIDTH, Item::HEIGHT};
|
||||
SDL_FRect src_rect = {.x = 0, .y = 0, .w = Item::WIDTH, .h = Item::HEIGHT};
|
||||
|
||||
// Disquito (desplazamiento 12/60 = 0.2s)
|
||||
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.2F) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||
@@ -134,7 +134,7 @@ void Instructions::fillTexture() {
|
||||
const int SPACE_BETWEEN_ITEM_LINES = Item::HEIGHT + item_space_;
|
||||
const int SPACE_NEW_PARAGRAPH = SPACE_BETWEEN_LINES * 0.5F;
|
||||
|
||||
const int SIZE = (NUM_LINES * SPACE_BETWEEN_LINES) + (NUM_ITEM_LINES * SPACE_BETWEEN_ITEM_LINES) + (NUM_POST_HEADERS * SPACE_POST_HEADER) + (NUM_PRE_HEADERS * SPACE_PRE_HEADER) + (SPACE_NEW_PARAGRAPH);
|
||||
const int SIZE = (NUM_LINES * SPACE_BETWEEN_LINES) + (NUM_ITEM_LINES * SPACE_BETWEEN_ITEM_LINES) + (NUM_POST_HEADERS * SPACE_POST_HEADER) + (NUM_PRE_HEADERS * SPACE_PRE_HEADER) + SPACE_NEW_PARAGRAPH;
|
||||
const int FIRST_LINE = (param.game.height - SIZE) / 2;
|
||||
|
||||
// Calcula cual es el texto más largo de las descripciones de los items
|
||||
@@ -333,8 +333,8 @@ auto Instructions::moveLines(std::vector<Line>& lines, int width, float duration
|
||||
// Método para renderizar las líneas
|
||||
void Instructions::renderLines(SDL_Renderer* renderer, SDL_Texture* texture, const std::vector<Line>& lines) {
|
||||
for (const auto& line : lines) {
|
||||
SDL_FRect src_rect = {0, static_cast<float>(line.y), 320, 1};
|
||||
SDL_FRect dst_rect = {static_cast<float>(line.x), static_cast<float>(line.y), 320, 1};
|
||||
SDL_FRect src_rect = {.x = 0, .y = static_cast<float>(line.y), .w = 320, .h = 1};
|
||||
SDL_FRect dst_rect = {.x = static_cast<float>(line.x), .y = static_cast<float>(line.y), .w = 320, .h = 1};
|
||||
SDL_RenderTexture(renderer, texture, &src_rect, &dst_rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Instructions {
|
||||
float elapsed_time_ = 0.0F; // Tiempo transcurrido (segundos)
|
||||
Uint64 last_time_ = 0; // Último timestamp para calcular delta-time
|
||||
SDL_FRect view_; // Vista del backbuffer que se va a mostrar por pantalla
|
||||
SDL_FPoint sprite_pos_ = {0, 0}; // Posición del primer sprite en la lista
|
||||
SDL_FPoint sprite_pos_ = {.x = 0, .y = 0}; // Posición del primer sprite en la lista
|
||||
float item_space_ = 2.0; // Espacio entre los items en pantalla
|
||||
std::vector<Line> lines_; // Vector que contiene las líneas animadas en la pantalla
|
||||
bool all_lines_off_screen_ = false; // Indica si todas las líneas han salido de la pantalla
|
||||
|
||||
@@ -311,13 +311,13 @@ void Intro::initSprites() {
|
||||
// Pone color en el marco de la textura
|
||||
auto color = param.intro.card_color;
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, color.a);
|
||||
SDL_FRect rect1 = {1, 0, CARD_WIDTH - 2, CARD_HEIGHT};
|
||||
SDL_FRect rect2 = {0, 1, CARD_WIDTH, CARD_HEIGHT - 2};
|
||||
SDL_FRect rect1 = {.x = 1, .y = 0, .w = CARD_WIDTH - 2, .h = CARD_HEIGHT};
|
||||
SDL_FRect rect2 = {.x = 0, .y = 1, .w = CARD_WIDTH, .h = CARD_HEIGHT - 2};
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect1);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect2);
|
||||
|
||||
// Copia la textura con la imagen dentro del marco
|
||||
SDL_FRect dest = {BORDER, BORDER, CARD_WIDTH - (BORDER * 2), CARD_HEIGHT - (BORDER * 2)};
|
||||
SDL_FRect dest = {.x = BORDER, .y = BORDER, .w = CARD_WIDTH - (BORDER * 2), .h = CARD_HEIGHT - (BORDER * 2)};
|
||||
SDL_RenderTexture(Screen::get()->getRenderer(), Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture(), nullptr, &dest);
|
||||
|
||||
// Deja el renderizador como estaba y añade la textura a la lista
|
||||
@@ -366,8 +366,8 @@ void Intro::initSprites() {
|
||||
// Dibuja la sombra sobre la textura
|
||||
auto shadow_color = param.intro.shadow_color;
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), shadow_color.r, shadow_color.g, shadow_color.b, Color::MAX_ALPHA_VALUE);
|
||||
SDL_FRect rect1 = {1, 0, SHADOW_SPRITE_WIDTH - 2, SHADOW_SPRITE_HEIGHT};
|
||||
SDL_FRect rect2 = {0, 1, SHADOW_SPRITE_WIDTH, SHADOW_SPRITE_HEIGHT - 2};
|
||||
SDL_FRect rect1 = {.x = 1, .y = 0, .w = SHADOW_SPRITE_WIDTH - 2, .h = SHADOW_SPRITE_HEIGHT};
|
||||
SDL_FRect rect2 = {.x = 0, .y = 1, .w = SHADOW_SPRITE_WIDTH, .h = SHADOW_SPRITE_HEIGHT - 2};
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect1);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect2);
|
||||
|
||||
@@ -522,7 +522,7 @@ void Intro::updatePostState() {
|
||||
|
||||
void Intro::renderTextRect() {
|
||||
static const float HEIGHT = Resource::get()->getText("04b_25_metal")->getCharacterSize();
|
||||
static SDL_FRect rect_ = {0.0F, param.game.height - param.intro.text_distance_from_bottom - HEIGHT, param.game.width, HEIGHT * 3};
|
||||
static SDL_FRect rect_ = {.x = 0.0F, .y = param.game.height - param.intro.text_distance_from_bottom - HEIGHT, .w = param.game.width, .h = HEIGHT * 3};
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), param.intro.shadow_color.r, param.intro.shadow_color.g, param.intro.shadow_color.b, param.intro.shadow_color.a);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||
}
|
||||
@@ -26,13 +26,13 @@ Logo::Logo()
|
||||
jail_texture_(Resource::get()->getTexture("logo_jailgames.png")) {
|
||||
// Inicializa variables
|
||||
Section::name = Section::Name::LOGO;
|
||||
dest_.x = param.game.game_area.center_x - jail_texture_->getWidth() / 2;
|
||||
dest_.y = param.game.game_area.center_y - jail_texture_->getHeight() / 2;
|
||||
dest_.x = param.game.game_area.center_x - (jail_texture_->getWidth() / 2);
|
||||
dest_.y = param.game.game_area.center_y - (jail_texture_->getHeight() / 2);
|
||||
since_sprite_->setPosition(SDL_FRect{
|
||||
static_cast<float>((param.game.width - since_texture_->getWidth()) / 2),
|
||||
static_cast<float>(SINCE_SPRITE_Y_OFFSET + jail_texture_->getHeight() + LOGO_SPACING),
|
||||
static_cast<float>(since_texture_->getWidth()),
|
||||
static_cast<float>(since_texture_->getHeight())});
|
||||
.x = static_cast<float>((param.game.width - since_texture_->getWidth()) / 2),
|
||||
.y = static_cast<float>(SINCE_SPRITE_Y_OFFSET + jail_texture_->getHeight() + LOGO_SPACING),
|
||||
.w = static_cast<float>(since_texture_->getWidth()),
|
||||
.h = static_cast<float>(since_texture_->getHeight())});
|
||||
since_sprite_->setY(dest_.y + jail_texture_->getHeight() + LOGO_SPACING);
|
||||
since_sprite_->setSpriteClip(0, 0, since_texture_->getWidth(), since_texture_->getHeight());
|
||||
since_texture_->setColor(SPECTRUM_BLACK.r, SPECTRUM_BLACK.g, SPECTRUM_BLACK.b);
|
||||
|
||||
@@ -207,9 +207,9 @@ void Title::decrementAllComponents(Color& color) {
|
||||
|
||||
void Title::printColorValue(const Color& color) {
|
||||
std::cout << "#"
|
||||
<< std::hex << std::setw(2) << std::setfill('0') << (int)color.r
|
||||
<< std::setw(2) << std::setfill('0') << (int)color.g
|
||||
<< std::setw(2) << std::setfill('0') << (int)color.b
|
||||
<< std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(color.r)
|
||||
<< std::setw(2) << std::setfill('0') << static_cast<int>(color.g)
|
||||
<< std::setw(2) << std::setfill('0') << static_cast<int>(color.b)
|
||||
<< '\n';
|
||||
}
|
||||
#endif
|
||||
@@ -586,7 +586,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::ranges::find_if(players_, [id](const auto& player) { return player->getId() == id; });
|
||||
auto it = std::ranges::find_if(players_, [id](const auto& player) -> auto { return player->getId() == id; });
|
||||
|
||||
if (it != players_.end()) {
|
||||
return *it;
|
||||
|
||||
Reference in New Issue
Block a user