clang-tidy readability

This commit is contained in:
2025-07-20 14:56:00 +02:00
parent f5245273a1
commit ca99f7be34
57 changed files with 623 additions and 557 deletions

View File

@@ -34,7 +34,7 @@ HiScoreTable::HiScoreTable()
background_(std::make_unique<Background>()),
ticks_(0),
view_area_(SDL_FRect{0, 0, static_cast<float>(param.game.width), static_cast<float>(param.game.height)}),
view_area_(SDL_FRect{0, 0, param.game.width, param.game.height}),
fade_mode_(FadeMode::IN),
background_fade_color_(Color(0, 0, 0)) {
// Inicializa el resto
@@ -83,7 +83,7 @@ void HiScoreTable::update() {
// Dibuja los sprites en la textura
void HiScoreTable::fillTexture() {
// Pinta en el backbuffer el texto y los sprites
auto temp = SDL_GetRenderTarget(renderer_);
auto *temp = SDL_GetRenderTarget(renderer_);
SDL_SetRenderTarget(renderer_, backbuffer_);
SDL_SetRenderDrawColor(renderer_, 0, 0, 0, 0);
SDL_RenderClear(renderer_);
@@ -112,7 +112,7 @@ void HiScoreTable::render() {
background_->render();
// Establece la ventana del backbuffer
view_area_.y = std::max(0.0f, param.game.height - counter_ + 100);
view_area_.y = std::max(0.0F, param.game.height - counter_ + 100);
// Copia el backbuffer al renderizador
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_area_);
@@ -218,7 +218,7 @@ void HiScoreTable::createSprites() {
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 ONE_CC = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : "";
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) {
dots = dots + ".";
@@ -301,16 +301,16 @@ void HiScoreTable::initFade() {
// Inicializa el fondo
void HiScoreTable::initBackground() {
background_->setPos(param.game.game_area.rect);
background_->setCloudsSpeed(-0.1f);
background_->setCloudsSpeed(-0.1F);
const int LUCKY = rand() % 3;
switch (LUCKY) {
case 0: // Fondo verde
{
background_->setGradientNumber(2);
background_->setTransition(0.0f);
background_->setSunProgression(1.0f);
background_->setMoonProgression(0.0f);
background_->setTransition(0.0F);
background_->setSunProgression(1.0F);
background_->setMoonProgression(0.0F);
background_fade_color_ = GREEN_SKY_COLOR;
break;
}
@@ -318,9 +318,9 @@ void HiScoreTable::initBackground() {
case 1: // Fondo naranja
{
background_->setGradientNumber(1);
background_->setTransition(0.0f);
background_->setSunProgression(0.65f);
background_->setMoonProgression(0.0f);
background_->setTransition(0.0F);
background_->setSunProgression(0.65F);
background_->setMoonProgression(0.0F);
background_fade_color_ = PINK_SKY_COLOR;
break;
}
@@ -328,9 +328,9 @@ void HiScoreTable::initBackground() {
case 2: // Fondo azul
{
background_->setGradientNumber(0);
background_->setTransition(0.0f);
background_->setSunProgression(0.0f);
background_->setMoonProgression(0.0f);
background_->setTransition(0.0F);
background_->setSunProgression(0.0F);
background_->setMoonProgression(0.0F);
background_fade_color_ = BLUE_SKY_COLOR;
break;
}

View File

@@ -62,9 +62,9 @@ class HiScoreTable {
// --- Métodos internos ---
void update(); // Actualiza las variables
void render(); // Pinta en pantalla
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
auto format(int number) -> std::string; // Convierte un entero a un string con separadores de miles
static void checkEvents(); // Comprueba los eventos
static void checkInput(); // Comprueba las entradas
static auto format(int number) -> std::string; // 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

View File

@@ -113,7 +113,7 @@ void Instructions::fillTexture() {
const int DESP_X = param.game.item_size + 8;
// Modifica el renderizador para pintar en la textura
auto temp = SDL_GetRenderTarget(renderer_);
auto *temp = SDL_GetRenderTarget(renderer_);
SDL_SetRenderTarget(renderer_, texture_);
// Limpia la textura
@@ -128,9 +128,9 @@ void Instructions::fillTexture() {
constexpr int SPACE_POST_HEADER = 20;
constexpr int SPACE_PRE_HEADER = 28;
const int SPACE_BETWEEN_LINES = text_->getCharacterSize() * 1.5f;
const int SPACE_BETWEEN_LINES = text_->getCharacterSize() * 1.5F;
const int SPACE_BETWEEN_ITEM_LINES = param.game.item_size + item_space_;
const int SPACE_NEW_PARAGRAPH = SPACE_BETWEEN_LINES * 0.5f;
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 FIRST_LINE = (param.game.height - SIZE) / 2;
@@ -182,7 +182,7 @@ void Instructions::fillTexture() {
// Rellena el backbuffer
void Instructions::fillBackbuffer() {
// Modifica el renderizador para pintar en la textura
auto temp = SDL_GetRenderTarget(renderer_);
auto *temp = SDL_GetRenderTarget(renderer_);
SDL_SetRenderTarget(renderer_, backbuffer_);
// Limpia la textura
@@ -242,10 +242,11 @@ void Instructions::render() {
tiled_bg_->render();
// Copia la textura y el backbuffer al renderizador
if (view_.y == 0)
if (view_.y == 0) {
renderLines(renderer_, backbuffer_, lines_);
else
} else {
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_);
}
fade_->render();
@@ -283,7 +284,7 @@ auto Instructions::initializeLines(int height) -> std::vector<Line> {
std::vector<Line> lines;
for (int y = 0; y < height; y++) {
int direction = (y % 2 == 0) ? -1 : 1; // Pares a la izquierda, impares a la derecha
lines.emplace_back(y, 0.0f, direction);
lines.emplace_back(y, 0.0F, direction);
}
return lines;
}
@@ -299,7 +300,7 @@ auto Instructions::moveLines(std::vector<Line> &lines, int width, float duration
line.start_time = current_time + line.y * start_delay;
}
float elapsed_time = (current_time - line.start_time) / 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;
@@ -329,7 +330,7 @@ void Instructions::renderLines(SDL_Renderer *renderer, SDL_Texture *texture, con
// Gestiona la textura con los graficos
void Instructions::updateBackbuffer() {
// Establece la ventana del backbuffer
view_.y = std::max(0.0f, param.game.height - counter_ + 100);
view_.y = std::max(0.0F, param.game.height - counter_ + 100);
// Verifica si view_.y == 0 y gestiona el temporizador
if (view_.y == 0) {
@@ -339,7 +340,7 @@ void Instructions::updateBackbuffer() {
start_delay_time_ = SDL_GetTicks();
} else if (SDL_GetTicks() - start_delay_time_ >= 4000) {
// Han pasado tres segundos, mover líneas
all_lines_off_screen_ = moveLines(lines_, 320, 1.0f, 5);
all_lines_off_screen_ = moveLines(lines_, 320, 1.0F, 5);
}
}

View File

@@ -74,14 +74,14 @@ class Instructions {
// --- Métodos internos ---
void update(); // Actualiza las variables
void render(); // Pinta en pantalla
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
static void checkEvents(); // Comprueba los eventos
static void checkInput(); // Comprueba las entradas
void fillTexture(); // Rellena la textura de texto
void fillBackbuffer(); // Rellena el backbuffer
void iniSprites(); // Inicializa los sprites de los items
void updateSprites(); // Actualiza los sprites
auto initializeLines(int height) -> std::vector<Line>; // Inicializa las líneas animadas
auto moveLines(std::vector<Line> &lines, int width, float duration, Uint32 start_delay) -> bool; // Mueve las líneas
void renderLines(SDL_Renderer *renderer, SDL_Texture *texture, const std::vector<Line> &lines); // Renderiza las líneas
static auto initializeLines(int height) -> std::vector<Line>; // Inicializa las líneas animadas
static auto moveLines(std::vector<Line> &lines, int width, float duration, Uint32 start_delay) -> bool; // Mueve las líneas
static 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
};

View File

@@ -42,7 +42,7 @@ Intro::Intro()
initTexts();
// Configura el fondo
tiled_bg_->setSpeed(0.3f);
tiled_bg_->setSpeed(0.3F);
tiled_bg_->setColor(bg_color_);
}
@@ -51,55 +51,67 @@ void Intro::checkEvents() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
#ifdef DEBUG
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
static Color color_ = param.intro.bg_color;
switch (event.key.key) {
case SDLK_A:
if (color_.r < 255)
if (color_.r < 255) {
++color_.r;
}
break;
case SDLK_Z:
if (color_.r > 0)
if (color_.r > 0) {
--color_.r;
}
break;
case SDLK_S:
if (color_.g < 255)
if (color_.g < 255) {
++color_.g;
}
break;
case SDLK_X:
if (color_.g > 0)
if (color_.g > 0) {
--color_.g;
}
break;
case SDLK_D:
if (color_.b < 255)
if (color_.b < 255) {
++color_.b;
}
break;
case SDLK_C:
if (color_.b > 0)
if (color_.b > 0) {
--color_.b;
}
break;
case SDLK_F:
if (color_.r < 255)
if (color_.r < 255) {
++color_.r;
if (color_.g < 255)
}
if (color_.g < 255) {
++color_.g;
if (color_.b < 255)
}
if (color_.b < 255) {
++color_.b;
}
break;
case SDLK_V:
if (color_.r > 0)
if (color_.r > 0) {
--color_.r;
if (color_.g > 0)
}
if (color_.g > 0) {
--color_.g;
if (color_.b > 0)
}
if (color_.b > 0) {
--color_.b;
}
break;
default:
@@ -335,7 +347,7 @@ void Intro::initSprites() {
// Constantes
constexpr int TOTAL_SPRITES = TEXTURE_LIST.size();
const float BORDER = 2.0f;
const float BORDER = 2.0F;
auto texture = Resource::get()->getTexture(TEXTURE_LIST.front());
const float CARD_WIDTH = texture->getWidth() + (BORDER * 2);
@@ -351,7 +363,7 @@ void Intro::initSprites() {
card_texture->setBlendMode(SDL_BLENDMODE_BLEND);
// Apuntamos el renderizador a la textura
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
auto *temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
card_texture->setAsRenderTarget(Screen::get()->getRenderer());
// Limpia la textura
@@ -406,7 +418,7 @@ void Intro::initSprites() {
shadow_texture->setBlendMode(SDL_BLENDMODE_BLEND);
// Apuntamos el renderizador a la textura
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
auto *temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
shadow_texture->setAsRenderTarget(Screen::get()->getRenderer());
// Limpia la textura
@@ -572,7 +584,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_ = {0.0F, param.game.height - param.intro.text_distance_from_bottom - HEIGHT, param.game.width, 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_);
}

View File

@@ -59,7 +59,7 @@ class Intro {
void update(); // Actualiza las variables del objeto
void render(); // Dibuja el objeto en pantalla
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
static void checkInput(); // Comprueba las entradas
void updateScenes(); // Actualiza las escenas de la intro
void initSprites(); // Inicializa las imágenes
void initTexts(); // Inicializa los textos
@@ -67,6 +67,6 @@ class Intro {
void updateTexts(); // Actualiza los textos
void renderSprites(); // Dibuja los sprites
void renderTexts(); // Dibuja los textos
void renderTextRect(); // Dibuja el rectangulo de fondo del texto;
static void renderTextRect(); // Dibuja el rectangulo de fondo del texto;
void updatePostState(); // Actualiza el estado POST
};

View File

@@ -52,8 +52,8 @@ class Logo {
// --- Métodos internos ---
void update(); // Actualiza las variables
void render(); // Dibuja en pantalla
void checkEvents(); // Comprueba el manejador de eventos
void checkInput(); // Comprueba las entradas
static void checkEvents(); // Comprueba el manejador de eventos
static void checkInput(); // Comprueba las entradas
void updateJAILGAMES(); // Gestiona el logo de JAILGAMES
void renderJAILGAMES(); // Renderiza el logo de JAILGAMES
void updateTextureColors(); // Gestiona el color de las texturas