diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 0000000..a3e6670 --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1 @@ +source/external/** \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy index fbf2f4a..f07142a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,8 +2,8 @@ Checks: > readability-identifier-naming WarningsAsErrors: '*' -# Excluir directorios third_party, external, vendor, etc. -HeaderFilterRegex: '^(?!.*(third_party|external|vendor|libs)).*' +# Solo incluir archivos de tu código fuente +HeaderFilterRegex: '^source/(sections|ui)/.*' FormatStyle: file CheckOptions: diff --git a/source/background.cpp b/source/background.cpp index 9ee7dbe..1a92d0a 100644 --- a/source/background.cpp +++ b/source/background.cpp @@ -74,20 +74,20 @@ Background::Background() // Inicializa objetos { - constexpr float top_clouds_speed = 0.1f; - constexpr float bottom_clouds_speed = 0.05f; + constexpr float TOP_CLOUDS_SPEED = 0.1f; + constexpr float BOTTOM_CLOUDS_SPEED = 0.05f; top_clouds_sprite_a_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight()); - top_clouds_sprite_a_->setVelX(-top_clouds_speed); + top_clouds_sprite_a_->setVelX(-TOP_CLOUDS_SPEED); top_clouds_sprite_b_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight()); - top_clouds_sprite_b_->setVelX(-top_clouds_speed); + top_clouds_sprite_b_->setVelX(-TOP_CLOUDS_SPEED); bottom_clouds_sprite_a_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight()); - bottom_clouds_sprite_a_->setVelX(-bottom_clouds_speed); + bottom_clouds_sprite_a_->setVelX(-BOTTOM_CLOUDS_SPEED); bottom_clouds_sprite_b_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight()); - bottom_clouds_sprite_b_->setVelX(-bottom_clouds_speed); + bottom_clouds_sprite_b_->setVelX(-BOTTOM_CLOUDS_SPEED); buildings_sprite_->setY(base_ - buildings_sprite_->getHeight()); grass_sprite_->setY(base_ - grass_sprite_->getHeight()); @@ -317,13 +317,13 @@ void Background::updateClouds() { // Precalcula el vector con el recorrido del sol void Background::createSunPath() { constexpr float CENTER_X = 170; - const float center_y = base_ - 80; + const float CENTER_Y = base_ - 80; constexpr float RADIUS = 120; // Generar puntos de la curva desde 90 a 180 grados for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) { float x = CENTER_X + (RADIUS * cos(theta)); - float y = center_y - (RADIUS * sin(theta)); + float y = CENTER_Y - (RADIUS * sin(theta)); sun_path_.push_back({x, y}); } @@ -338,13 +338,13 @@ void Background::createSunPath() { // Precalcula el vector con el recorrido de la luna void Background::createMoonPath() { constexpr float CENTER_X = 100; - const float center_y = base_ - 50; + const float CENTER_Y = base_ - 50; constexpr float RADIUS = 140; // Generar puntos de la curva desde 0 a 90 grados for (double theta = 0; theta <= M_PI / 2; theta += 0.01) { float x = CENTER_X + (RADIUS * cos(theta)); - float y = center_y - (RADIUS * sin(theta)); + float y = CENTER_Y - (RADIUS * sin(theta)); moon_path_.push_back({x, y}); } } diff --git a/source/balloon.cpp b/source/balloon.cpp index c83635c..ea34561 100644 --- a/source/balloon.cpp +++ b/source/balloon.cpp @@ -30,15 +30,15 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel vy_ = 0; max_vy_ = 3.0f; - const int index = static_cast(size_); - gravity_ = param.balloon.settings.at(index).grav; - default_vy_ = param.balloon.settings.at(index).vel; - h_ = w_ = BALLOON_SIZE[index]; - power_ = BALLOON_POWER[index]; - menace_ = BALLOON_MENACE[index]; - score_ = BALLOON_SCORE[index]; - bouncing_sound_ = BALLOON_BOUNCING_SOUND[index]; - popping_sound_ = BALLOON_POPPING_SOUND[index]; + const int INDEX = static_cast(size_); + gravity_ = param.balloon.settings.at(INDEX).grav; + default_vy_ = param.balloon.settings.at(INDEX).vel; + h_ = w_ = BALLOON_SIZE[INDEX]; + power_ = BALLOON_POWER[INDEX]; + menace_ = BALLOON_MENACE[INDEX]; + score_ = BALLOON_SCORE[INDEX]; + bouncing_sound_ = BALLOON_BOUNCING_SOUND[INDEX]; + popping_sound_ = BALLOON_POPPING_SOUND[INDEX]; break; } @@ -47,19 +47,19 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0f); gravity_ = 0.00f; - const int index = static_cast(size_); - h_ = w_ = BALLOON_SIZE[index]; - power_ = BALLOON_POWER[index]; - menace_ = BALLOON_MENACE[index]; - score_ = BALLOON_SCORE[index]; - bouncing_sound_ = BALLOON_BOUNCING_SOUND[index]; - popping_sound_ = BALLOON_POPPING_SOUND[index]; + const int INDEX = static_cast(size_); + h_ = w_ = BALLOON_SIZE[INDEX]; + power_ = BALLOON_POWER[INDEX]; + menace_ = BALLOON_MENACE[INDEX]; + score_ = BALLOON_SCORE[INDEX]; + bouncing_sound_ = BALLOON_BOUNCING_SOUND[INDEX]; + popping_sound_ = BALLOON_POPPING_SOUND[INDEX]; break; } case BalloonType::POWERBALL: { - constexpr int index = 3; + constexpr int INDEX = 3; h_ = w_ = BALLOON_SIZE[4]; bouncing_sound_ = BALLOON_BOUNCING_SOUND[3]; popping_sound_ = "power_ball_explosion.wav"; @@ -67,8 +67,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel vy_ = 0; max_vy_ = 3.0f; - gravity_ = param.balloon.settings.at(index).grav; - default_vy_ = param.balloon.settings.at(index).vel; + gravity_ = param.balloon.settings.at(INDEX).grav; + default_vy_ = param.balloon.settings.at(INDEX).vel; sprite_->setRotate(creation_timer <= 0); sprite_->setRotateAmount(vx_ > 0.0f ? 2.0 : -2.0); @@ -96,9 +96,9 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel // Centra el globo en la posición X void Balloon::alignTo(int x) { x_ = static_cast(x - (w_ / 2)); - const int min_x = play_area_.x; - const int max_x = play_area_.w - w_; - x_ = std::clamp(x_, static_cast(min_x), static_cast(max_x)); + const int MIN_X = play_area_.x; + const int MAX_X = play_area_.w - w_; + x_ = std::clamp(x_, static_cast(MIN_X), static_cast(MAX_X)); } // Pinta el globo en la pantalla @@ -146,13 +146,13 @@ void Balloon::move() { x_ += vx_ * speed_; // Colisión en las partes laterales de la zona de juego - const int clip = 2; - const float min_x = play_area_.x - clip; - const float max_x = play_area_.x + play_area_.w - w_ + clip; - if (x_ < min_x || x_ > max_x) { + const int CLIP = 2; + const float MIN_X = play_area_.x - CLIP; + const float MAX_X = play_area_.x + play_area_.w - w_ + CLIP; + if (x_ < MIN_X || x_ > MAX_X) { if (bouncing_sound_enabled_) playSound(bouncing_sound_); - x_ = std::clamp(x_, min_x, max_x); + x_ = std::clamp(x_, MIN_X, MAX_X); vx_ = -vx_; // Activa el efecto de rebote o invierte la rotación if (type_ == BalloonType::POWERBALL) { @@ -167,22 +167,22 @@ void Balloon::move() { // Colisión en la parte superior solo si el globo va de subida if (vy_ < 0) { - const int min_y = play_area_.y; - if (y_ < min_y) { + const int MIN_Y = play_area_.y; + if (y_ < MIN_Y) { if (bouncing_sound_enabled_) playSound(bouncing_sound_); - y_ = min_y; + y_ = MIN_Y; vy_ = -vy_; enableBounce(); } } // Colisión en la parte inferior de la zona de juego - const int max_y = play_area_.y + play_area_.h - h_; - if (y_ > max_y) { + const int MAX_Y = play_area_.y + play_area_.h - h_; + if (y_ > MAX_Y) { if (bouncing_sound_enabled_) playSound(bouncing_sound_); - y_ = max_y; + y_ = MAX_Y; vy_ = -default_vy_; if (type_ != BalloonType::POWERBALL) { enableBounce(); @@ -240,10 +240,10 @@ void Balloon::updateState() { x_ += vx_; // Comprueba no se salga por los laterales - const int min_x = play_area_.x; - const int max_x = play_area_.w - w_; + const int MIN_X = play_area_.x; + const int MAX_X = play_area_.w - w_; - if (x_ < min_x || x_ > max_x) { + if (x_ < MIN_X || x_ > MAX_X) { // Corrige y cambia el sentido de la velocidad x_ -= vx_; vx_ = -vx_; @@ -340,9 +340,9 @@ void Balloon::disableBounce() { // Aplica el efecto void Balloon::updateBounce() { if (bouncing_.enabled) { - const int index = bouncing_.counter / bouncing_.speed; - bouncing_.zoomW = bouncing_.w[index]; - bouncing_.zoomH = bouncing_.h[index]; + const int INDEX = bouncing_.counter / bouncing_.speed; + bouncing_.zoomW = bouncing_.w[INDEX]; + bouncing_.zoomH = bouncing_.h[INDEX]; zoomSprite(); @@ -371,8 +371,8 @@ void Balloon::playSound(const std::string &name) { if (!sound_enabled_) return; - static auto audio = Audio::get(); - audio->playSound(name); + static auto audio_ = Audio::get(); + audio_->playSound(name); } // Explota el globo diff --git a/source/balloon_formations.cpp b/source/balloon_formations.cpp index 041a7b6..0e6c4e2 100644 --- a/source/balloon_formations.cpp +++ b/source/balloon_formations.cpp @@ -5,22 +5,22 @@ #include "utils.h" // Para ParamGame, Param, Zone, BLOCK void BalloonFormations::initBalloonFormations() { - constexpr int y4 = -BLOCK; - const int x4_0 = param.game.play_area.rect.x; - const int x4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3]; + constexpr int Y4 = -BLOCK; + const int X4_0 = param.game.play_area.rect.x; + const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3]; - constexpr int y3 = -BLOCK; - const int x3_0 = param.game.play_area.rect.x; - const int x3_100 = param.game.play_area.rect.w - BALLOON_SIZE[2]; + constexpr int Y3 = -BLOCK; + const int X3_0 = param.game.play_area.rect.x; + const int X3_100 = param.game.play_area.rect.w - BALLOON_SIZE[2]; - constexpr int y2 = -BLOCK; - const int x2_0 = param.game.play_area.rect.x; - const int x2_100 = param.game.play_area.rect.w - BALLOON_SIZE[1]; + constexpr int Y2 = -BLOCK; + const int X2_0 = param.game.play_area.rect.x; + const int X2_100 = param.game.play_area.rect.w - BALLOON_SIZE[1]; - constexpr int y1 = -BLOCK; - const int x1_0 = param.game.play_area.rect.x; - const int x1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2); - const int x1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0]; + constexpr int Y1 = -BLOCK; + const int X1_0 = param.game.play_area.rect.x; + const int X1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2); + const int X1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0]; balloon_formation_.reserve(NUMBER_OF_BALLOON_FORMATIONS); @@ -29,16 +29,16 @@ void BalloonFormations::initBalloonFormations() { // #00 - Dos enemigos BALLOON4 uno a cada extremo { std::vector init_params = { - BalloonFormationParams(x4_0, y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME), - BalloonFormationParams(x4_100, y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)}; + BalloonFormationParams(X4_0, Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME), + BalloonFormationParams(X4_100, Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)}; balloon_formation_.emplace_back(2, init_params); } // #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro { std::vector init_params = { - BalloonFormationParams(param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME), - BalloonFormationParams(param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)}; + BalloonFormationParams(param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME), + BalloonFormationParams(param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME)}; balloon_formation_.emplace_back(2, init_params); } @@ -46,7 +46,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 4; ++i) { - init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); + init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(4, init_params); } @@ -55,7 +55,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 4; ++i) { - init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); + init_params.emplace_back(X2_100 - (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(4, init_params); } @@ -64,7 +64,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -73,7 +73,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -82,7 +82,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -91,7 +91,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -100,7 +100,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 6; ++i) { - init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); + init_params.emplace_back(X1_0 + (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(6, init_params); } @@ -109,7 +109,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 6; ++i) { - init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); + init_params.emplace_back(X1_100 - (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(6, init_params); } @@ -118,7 +118,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i)); + init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -127,7 +127,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 3; ++i) { - init_params.emplace_back(x4_100 - (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i)); + init_params.emplace_back(X4_100 - (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME - (15 * i)); } balloon_formation_.emplace_back(3, init_params); } @@ -136,7 +136,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 6; ++i) { - init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); + init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(6, init_params); } @@ -145,7 +145,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 6; ++i) { - init_params.emplace_back(x2_100 - (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); + init_params.emplace_back(X2_100 - (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(6, init_params); } @@ -154,7 +154,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 5; ++i) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(5, init_params); } @@ -163,7 +163,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 5; ++i) { - init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(5, init_params); } @@ -172,7 +172,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 5; ++i) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(5, init_params); } @@ -181,7 +181,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 5; ++i) { - init_params.emplace_back(x3_100 - (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + init_params.emplace_back(X3_100 - (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(5, init_params); } @@ -190,7 +190,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 12; ++i) { - init_params.emplace_back(x1_0 + (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); + init_params.emplace_back(X1_0 + (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(12, init_params); } @@ -199,7 +199,7 @@ void BalloonFormations::initBalloonFormations() { { std::vector init_params; for (int i = 0; i < 12; ++i) { - init_params.emplace_back(x1_100 - (i * (BALLOON_SIZE[0] + 1)), y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); + init_params.emplace_back(X1_100 - (i * (BALLOON_SIZE[0] + 1)), Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (10 * i)); } balloon_formation_.emplace_back(12, init_params); } @@ -207,12 +207,12 @@ void BalloonFormations::initBalloonFormations() { // #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos { std::vector init_params; - const int half = 4 / 2; + const int HALF = 4 / 2; for (int i = 0; i < 4; ++i) { - if (i < half) { - init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); + if (i < HALF) { + init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); } else { - init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); + init_params.emplace_back(X4_100 - ((i - HALF) * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); } } balloon_formation_.emplace_back(4, init_params); @@ -221,12 +221,12 @@ void BalloonFormations::initBalloonFormations() { // #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simétricos { std::vector init_params; - const int half = 4 / 2; + const int HALF = 4 / 2; for (int i = 0; i < 4; ++i) { - if (i < half) { - init_params.emplace_back(x4_0 + (i * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); + if (i < HALF) { + init_params.emplace_back(X4_0 + (i * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); } else { - init_params.emplace_back(x4_100 - ((i - half) * (BALLOON_SIZE[3] + 1)), y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); + init_params.emplace_back(X4_100 - ((i - HALF) * (BALLOON_SIZE[3] + 1)), Y4, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE4, CREATION_TIME + (0 * i)); } } balloon_formation_.emplace_back(4, init_params); @@ -235,12 +235,12 @@ void BalloonFormations::initBalloonFormations() { // #21 - Diez enemigos BALLOON2 uno detrás del otro. Izquierda/derecha. Simétricos { std::vector init_params; - const int half = 10 / 2; + const int HALF = 10 / 2; for (int i = 0; i < 10; ++i) { - if (i < half) { - init_params.emplace_back(x2_0 + (i * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * i)); + if (i < HALF) { + init_params.emplace_back(X2_0 + (i * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * i)); } else { - init_params.emplace_back(x2_100 - ((i - half) * (BALLOON_SIZE[1] + 1)), y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * (i - half))); + init_params.emplace_back(X2_100 - ((i - HALF) * (BALLOON_SIZE[1] + 1)), Y2, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE2, CREATION_TIME - (3 * (i - HALF))); } } balloon_formation_.emplace_back(10, init_params); @@ -249,12 +249,12 @@ void BalloonFormations::initBalloonFormations() { // #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simétricos { std::vector init_params; - const int half = 10 / 2; + const int HALF = 10 / 2; for (int i = 0; i < 10; ++i) { - if (i < half) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + if (i < HALF) { + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } else { - init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] * 2)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half))); + init_params.emplace_back(X3_100 - ((i - HALF) * (BALLOON_SIZE[2] * 2)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - HALF))); } } balloon_formation_.emplace_back(10, init_params); @@ -263,12 +263,12 @@ void BalloonFormations::initBalloonFormations() { // #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simétricos { std::vector init_params; - const int half = 10 / 2; + const int HALF = 10 / 2; for (int i = 0; i < 10; ++i) { - if (i < half) { - init_params.emplace_back(x3_0 + (i * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); + if (i < HALF) { + init_params.emplace_back(X3_0 + (i * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * i)); } else { - init_params.emplace_back(x3_100 - ((i - half) * (BALLOON_SIZE[2] + 1)), y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - half))); + init_params.emplace_back(X3_100 - ((i - HALF) * (BALLOON_SIZE[2] + 1)), Y3, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE3, CREATION_TIME - (10 * (i - HALF))); } } balloon_formation_.emplace_back(10, init_params); @@ -277,12 +277,12 @@ void BalloonFormations::initBalloonFormations() { // #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simétricos { std::vector init_params; - const int half = 30 / 2; + const int HALF = 30 / 2; for (int i = 0; i < 30; ++i) { - if (i < half) { - init_params.emplace_back(x1_50, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * i)); + if (i < HALF) { + init_params.emplace_back(X1_50, Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * i)); } else { - init_params.emplace_back(x1_50, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * (i - half))); + init_params.emplace_back(X1_50, Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME + (5 * (i - HALF))); } } balloon_formation_.emplace_back(30, init_params); @@ -291,12 +291,12 @@ void BalloonFormations::initBalloonFormations() { // #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simétricos { std::vector init_params; - const int half = 30 / 2; + const int HALF = 30 / 2; for (int i = 0; i < 30; ++i) { - if (i < half) { - init_params.emplace_back(x1_50 + 20, y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * i)); + if (i < HALF) { + init_params.emplace_back(X1_50 + 20, Y1, BALLOON_VELX_NEGATIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * i)); } else { - init_params.emplace_back(x1_50 - 20, y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * (i - half))); + init_params.emplace_back(X1_50 - 20, Y1, BALLOON_VELX_POSITIVE, BalloonType::BALLOON, BalloonSize::SIZE1, CREATION_TIME - (5 * (i - HALF))); } } balloon_formation_.emplace_back(30, init_params); @@ -322,10 +322,10 @@ void BalloonFormations::initBalloonFormations() { // TEST std::vector test_params = { - {10, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE1, 200}, - {50, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE2, 200}, - {90, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200}, - {140, y1, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}}; + {10, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE1, 200}, + {50, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE2, 200}, + {90, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200}, + {140, Y1, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}}; balloon_formation_.at(99) = BalloonFormationUnit(4, test_params); } diff --git a/source/balloon_manager.cpp b/source/balloon_manager.cpp index 469b000..6d1c171 100644 --- a/source/balloon_manager.cpp +++ b/source/balloon_manager.cpp @@ -96,10 +96,10 @@ void BalloonManager::deployBalloonFormation(int stage) { last_balloon_deploy_ = formation; - const auto set = balloon_formations_->getSet(stage, formation); - const auto num_enemies = set.number_of_balloons; - for (int i = 0; i < num_enemies; ++i) { - auto p = set.init[i]; + const auto SET = balloon_formations_->getSet(stage, formation); + const auto NUM_ENEMIES = SET.number_of_balloons; + for (int i = 0; i < NUM_ENEMIES; ++i) { + auto p = SET.init[i]; createBalloon( p.x, p.y, @@ -117,20 +117,20 @@ void BalloonManager::deployBalloonFormation(int stage) { // Crea una formación de enemigos específica void BalloonManager::deploySet(int set_number) { - const auto set = balloon_formations_->getSet(set_number); - const auto num_enemies = set.number_of_balloons; - for (int i = 0; i < num_enemies; ++i) { - auto p = set.init[i]; + const auto SET = balloon_formations_->getSet(set_number); + const auto NUM_ENEMIES = SET.number_of_balloons; + for (int i = 0; i < NUM_ENEMIES; ++i) { + auto p = SET.init[i]; createBalloon(p.x, p.y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter); } } // Crea una formación de enemigos específica void BalloonManager::deploySet(int set_number, int y) { - const auto set = balloon_formations_->getSet(set_number); - const auto num_enemies = set.number_of_balloons; - for (int i = 0; i < num_enemies; ++i) { - auto p = set.init[i]; + const auto SET = balloon_formations_->getSet(set_number); + const auto NUM_ENEMIES = SET.number_of_balloons; + for (int i = 0; i < NUM_ENEMIES; ++i) { + auto p = SET.init[i]; createBalloon(p.x, y, p.type, p.size, p.vel_x, balloon_speed_, p.creation_counter); } } @@ -340,14 +340,14 @@ void BalloonManager::createTwoBigBalloons() { // Crea una disposición de globos aleatoria void BalloonManager::createRandomBalloons() { - const int num_balloons = 2 + rand() % 4; - for (int i = 0; i < num_balloons; ++i) { - const float x = param.game.game_area.rect.x + (rand() % static_cast(param.game.game_area.rect.w)) - BALLOON_SIZE[3]; - const int y = param.game.game_area.rect.y + (rand() % 50); - const BalloonSize size = static_cast(rand() % 4); - const float vel_x = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE; - const int creation_counter = 0; - createBalloon(x, y, BalloonType::BALLOON, size, vel_x, balloon_speed_, creation_counter); + const int NUM_BALLOONS = 2 + rand() % 4; + for (int i = 0; i < NUM_BALLOONS; ++i) { + const float X = param.game.game_area.rect.x + (rand() % static_cast(param.game.game_area.rect.w)) - BALLOON_SIZE[3]; + const int Y = param.game.game_area.rect.y + (rand() % 50); + const BalloonSize SIZE = static_cast(rand() % 4); + const float VEL_X = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE; + const int CREATION_COUNTER = 0; + createBalloon(X, Y, BalloonType::BALLOON, SIZE, VEL_X, balloon_speed_, CREATION_COUNTER); } } diff --git a/source/define_buttons.cpp b/source/define_buttons.cpp index 218129a..a62b815 100644 --- a/source/define_buttons.cpp +++ b/source/define_buttons.cpp @@ -38,9 +38,9 @@ void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event) return; } - const auto button = static_cast(event.button); - if (checkButtonNotInUse(button)) { - buttons_.at(index_button_).button = button; + const auto BUTTON = static_cast(event.button); + if (checkButtonNotInUse(BUTTON)) { + buttons_.at(index_button_).button = BUTTON; incIndexButton(); } } diff --git a/source/director.cpp b/source/director.cpp index cfcc8e1..3e9db30 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -126,9 +126,9 @@ void Director::loadParams() { #ifdef ANBERNIC const std::string paramFilePath = asset->get("param_320x240.txt"); #else - const std::string paramFilePath = overrides.param_file == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt"); + const std::string PARAM_FILE_PATH = overrides.param_file == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt"); #endif - loadParamsFromFile(paramFilePath); + loadParamsFromFile(PARAM_FILE_PATH); } // Carga el fichero de puntuaciones @@ -205,8 +205,8 @@ void Director::bindInputs() { } // Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso - const size_t max_controllers = std::min(2, NUM_GAMEPADS); - for (size_t i = 0; i < max_controllers; ++i) { + const size_t MAX_CONTROLLERS = std::min(2, NUM_GAMEPADS); + for (size_t i = 0; i < MAX_CONTROLLERS; ++i) { for (auto &controller : Options::controllers) { if (Input::get()->getControllerName(i) == controller.name) { for (size_t j = 0; j < controller.inputs.size(); ++j) { @@ -224,7 +224,7 @@ void Director::bindInputs() { } // Guarda las asignaciones de botones en las opciones de los dos primeros mandos - for (size_t i = 0; i < max_controllers; ++i) { + for (size_t i = 0; i < MAX_CONTROLLERS; ++i) { // Variables asociadas al mando Options::controllers.at(i).index = i; Options::controllers.at(i).name = Input::get()->getControllerName(i); @@ -246,186 +246,186 @@ void Director::setFileList() { #ifdef MACOS_BUNDLE const std::string prefix = "/../Resources"; #else - const std::string prefix; + const std::string PREFIX; #endif // Ficheros de configuración Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true); Asset::get()->add(system_folder_ + "/score.bin", AssetType::DATA, false, true); - Asset::get()->add(prefix + "/data/config/param_320x240.txt", AssetType::DATA); - Asset::get()->add(prefix + "/data/config/param_320x256.txt", AssetType::DATA); - Asset::get()->add(prefix + "/data/config/demo1.bin", AssetType::DEMODATA); - Asset::get()->add(prefix + "/data/config/demo2.bin", AssetType::DEMODATA); - Asset::get()->add(prefix + "/data/config/gamecontrollerdb.txt", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/config/param_320x240.txt", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/config/param_320x256.txt", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/config/demo1.bin", AssetType::DEMODATA); + Asset::get()->add(PREFIX + "/data/config/demo2.bin", AssetType::DEMODATA); + Asset::get()->add(PREFIX + "/data/config/gamecontrollerdb.txt", AssetType::DATA); // Musicas - Asset::get()->add(prefix + "/data/music/intro.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/playing.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/title.ogg", AssetType::MUSIC); - Asset::get()->add(prefix + "/data/music/credits.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/intro.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/playing.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/title.ogg", AssetType::MUSIC); + Asset::get()->add(PREFIX + "/data/music/credits.ogg", AssetType::MUSIC); // Sonidos - Asset::get()->add(prefix + "/data/sound/balloon1.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/balloon2.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/balloon3.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/balloon4.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/bubble1.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/bubble2.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/bubble3.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/bubble4.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/bullet.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/clock.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/coffee_out.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/continue_clock.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/debian_drop.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/debian_pickup.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/hi_score_achieved.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/item_drop.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/item_pickup.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/jump.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/logo.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/player_collision.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/power_ball_explosion.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/service_menu_adjust.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/service_menu_move.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/service_menu_select.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/stage_change.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/tabe_hit.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/tabe.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/title.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_aw_aw_aw.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_coffee.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_get_ready.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_no.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_power_up.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/voice_thankyou.wav", AssetType::SOUND); - Asset::get()->add(prefix + "/data/sound/walk.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/balloon1.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/balloon2.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/balloon3.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/balloon4.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/bubble1.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/bubble2.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/bubble3.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/bubble4.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/bullet.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/clock.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/coffee_out.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/continue_clock.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/debian_drop.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/debian_pickup.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/hi_score_achieved.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/item_drop.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/item_pickup.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/jump.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/logo.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/notify.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/player_collision.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/power_ball_explosion.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/service_menu_adjust.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/service_menu_move.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/service_menu_select.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/stage_change.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/tabe_hit.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/tabe.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/title.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_aw_aw_aw.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_coffee.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_get_ready.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_no.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_power_up.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/voice_thankyou.wav", AssetType::SOUND); + Asset::get()->add(PREFIX + "/data/sound/walk.wav", AssetType::SOUND); // Shaders - Asset::get()->add(prefix + "/data/shaders/crtpi_256.glsl", AssetType::DATA); - Asset::get()->add(prefix + "/data/shaders/crtpi_240.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_256.glsl", AssetType::DATA); + Asset::get()->add(PREFIX + "/data/shaders/crtpi_240.glsl", AssetType::DATA); // Texturas - Balloons - Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION); // Texturas - Explosiones - Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION); // Texturas - Power Ball - Asset::get()->add(prefix + "/data/gfx/balloon/powerball.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION); // Texturas - Bala - Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/bullet/bullet.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/bullet/bullet.ani", AssetType::ANIMATION); // Texturas - Tabe - Asset::get()->add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION); // Texturas - Juego - Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_grass.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_sun.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_buildings.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_grass.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_sun.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/game/game_moon.png", AssetType::BITMAP); // Texturas - Intro - Asset::get()->add(prefix + "/data/gfx/intro/intro1.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/intro/intro2.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/intro/intro3.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/intro/intro4.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/intro/intro5.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/intro/intro6.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro1.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro2.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro3.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro4.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro5.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/intro/intro6.png", AssetType::BITMAP); // Texturas - Logo - Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP); // Texturas - Items - Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_clock.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_coffee.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_debian.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION); // Texturas - Titulo - Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/title/title_coffee.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/title/title_crisis.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/title/title_dust.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/title/title_coffee.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/title/title_crisis.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION); // Texturas - Jugador 1 - Asset::get()->add(prefix + "/data/gfx/player/player1.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/player/player1_coffee1.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player1_coffee2.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player1_invencible.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player1_power.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/player/player1.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee1.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player1_coffee2.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player1_invencible.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player1_power.png", AssetType::BITMAP); // Texturas - Jugador 2 - Asset::get()->add(prefix + "/data/gfx/player/player2.gif", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/gfx/player/player2_coffee1.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player2_coffee2.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player2_invencible.pal", AssetType::PALETTE); - Asset::get()->add(prefix + "/data/gfx/player/player2_power.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/player/player2.gif", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee1.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player2_coffee2.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player2_invencible.pal", AssetType::PALETTE); + Asset::get()->add(PREFIX + "/data/gfx/player/player2_power.png", AssetType::BITMAP); // Animaciones del jugador - Asset::get()->add(prefix + "/data/gfx/player/player.ani", AssetType::ANIMATION); - Asset::get()->add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/player/player.ani", AssetType::ANIMATION); + Asset::get()->add(PREFIX + "/data/gfx/player/player_power.ani", AssetType::ANIMATION); // Fuentes de texto - Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/aseprite.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/aseprite.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/smb2.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/smb2_grad.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/04b_25.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/04b_25_2x.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT); - Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_flat.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_reversed.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP); - Asset::get()->add(prefix + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/8bithud.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/8bithud.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/aseprite.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/aseprite.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/smb2.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/smb2_grad.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/smb2.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/04b_25.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/04b_25_2x.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_2x.txt", AssetType::FONT); + Asset::get()->add(PREFIX + "/data/font/04b_25_metal.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_grey.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_flat.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_reversed.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP); + Asset::get()->add(PREFIX + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP); // Textos - Asset::get()->add(prefix + "/data/lang/es_ES.json", AssetType::LANG); - Asset::get()->add(prefix + "/data/lang/en_UK.json", AssetType::LANG); - Asset::get()->add(prefix + "/data/lang/ba_BA.json", AssetType::LANG); + Asset::get()->add(PREFIX + "/data/lang/es_ES.json", AssetType::LANG); + Asset::get()->add(PREFIX + "/data/lang/en_UK.json", AssetType::LANG); + Asset::get()->add(PREFIX + "/data/lang/ba_BA.json", AssetType::LANG); // Si falta algun fichero, sale del programa if (!Asset::get()->check()) { diff --git a/source/fade.cpp b/source/fade.cpp index c1c951a..5dc90b4 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -156,8 +156,8 @@ void Fade::update() { SDL_SetRenderDrawColor(renderer_, r_, g_, b_, a_); // Dibuja el cuadrado correspondiente - for (const auto rect : square_) { - SDL_RenderFillRect(renderer_, &rect); + for (const auto RECT : square_) { + SDL_RenderFillRect(renderer_, &RECT); } // Deja el renderizador como estaba @@ -165,10 +165,10 @@ void Fade::update() { SDL_SetRenderTarget(renderer_, temp); // Modifica el tamaño de los rectangulos - const auto h = counter_ / 2; + const auto H = counter_ / 2; for (size_t i = 0; i < square_.size(); ++i) { // A partir del segundo rectangulo se pinta en función del anterior - square_.at(i).h = i == 0 ? h : std::max(static_cast(square_.at(i - 1).h) - 2, 0); + square_.at(i).h = i == 0 ? H : std::max(static_cast(square_.at(i - 1).h) - 2, 0); } int completed = 0; diff --git a/source/game_logo.cpp b/source/game_logo.cpp index d17456c..684984d 100644 --- a/source/game_logo.cpp +++ b/source/game_logo.cpp @@ -35,8 +35,8 @@ GameLogo::GameLogo(int x, int y) // Inicializa las variables void GameLogo::init() { - const auto xp = x_ - coffee_texture_->getWidth() / 2; - const auto desp = getInitialVerticalDesp(); + const auto XP = x_ - coffee_texture_->getWidth() / 2; + const auto DESP = getInitialVerticalDesp(); // Configura texturas SDL_SetTextureScaleMode(Resource::get()->getTexture("title_arcade_edition.png")->getSDLTexture(), SDL_SCALEMODE_NEAREST); @@ -44,12 +44,12 @@ void GameLogo::init() { // Variables coffee_crisis_status_ = Status::DISABLED; arcade_edition_status_ = Status::DISABLED; - shake_.init(1, 2, 8, xp); + shake_.init(1, 2, 8, XP); zoom_ = 3.0f * ZOOM_FACTOR; // Inicializa el bitmap de 'Coffee' - coffee_sprite_->setPosX(xp); - coffee_sprite_->setPosY(y_ - coffee_texture_->getHeight() - desp); + coffee_sprite_->setPosX(XP); + coffee_sprite_->setPosY(y_ - coffee_texture_->getHeight() - DESP); coffee_sprite_->setWidth(coffee_texture_->getWidth()); coffee_sprite_->setHeight(coffee_texture_->getHeight()); coffee_sprite_->setVelX(0.0f); @@ -59,12 +59,12 @@ void GameLogo::init() { coffee_sprite_->setSpriteClip(0, 0, coffee_texture_->getWidth(), coffee_texture_->getHeight()); coffee_sprite_->setEnabled(true); coffee_sprite_->setFinishedCounter(0); - coffee_sprite_->setDestX(xp); + coffee_sprite_->setDestX(XP); coffee_sprite_->setDestY(y_ - coffee_texture_->getHeight()); // Inicializa el bitmap de 'Crisis' - crisis_sprite_->setPosX(xp + 15); - crisis_sprite_->setPosY(y_ + desp); + crisis_sprite_->setPosX(XP + 15); + crisis_sprite_->setPosY(y_ + DESP); crisis_sprite_->setWidth(crisis_texture_->getWidth()); crisis_sprite_->setHeight(crisis_texture_->getHeight()); crisis_sprite_->setVelX(0.0f); @@ -74,7 +74,7 @@ void GameLogo::init() { crisis_sprite_->setSpriteClip(0, 0, crisis_texture_->getWidth(), crisis_texture_->getHeight()); crisis_sprite_->setEnabled(true); crisis_sprite_->setFinishedCounter(0); - crisis_sprite_->setDestX(xp + 15); + crisis_sprite_->setDestX(XP + 15); crisis_sprite_->setDestY(y_); // Inicializa el bitmap de 'DustRight' @@ -138,9 +138,9 @@ void GameLogo::update() { shake_.counter--; } else { shake_.counter = shake_.delay; - const auto desp = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp; - coffee_sprite_->setPosX(shake_.origin + desp); - crisis_sprite_->setPosX(shake_.origin + desp + 15); + const auto DESP = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp; + coffee_sprite_->setPosX(shake_.origin + DESP); + crisis_sprite_->setPosX(shake_.origin + DESP + 15); shake_.remaining--; } } else { @@ -190,8 +190,8 @@ void GameLogo::update() { shake_.counter--; } else { shake_.counter = shake_.delay; - const auto desp = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp; - arcade_edition_sprite_->setX(shake_.origin + desp); + const auto DESP = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp; + arcade_edition_sprite_->setX(shake_.origin + DESP); shake_.remaining--; } } else { diff --git a/source/input.cpp b/source/input.cpp index 361b25b..f0c8bd3 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -57,13 +57,13 @@ void Input::bindGameControllerButton(int controller_index, InputAction input_tar bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int controller_index) { bool success_keyboard = false; bool success_controller = false; - const int input_index = static_cast(input); + const int INPUT_INDEX = static_cast(input); if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) { if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido) - success_keyboard = key_bindings_[input_index].is_held; + success_keyboard = key_bindings_[INPUT_INDEX].is_held; } else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma) - success_keyboard = key_bindings_[input_index].just_pressed; + success_keyboard = key_bindings_[INPUT_INDEX].just_pressed; } } @@ -73,9 +73,9 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c if (!success_controller) { if (repeat) { // El usuario quiere saber si está pulsada (estado mantenido) - success_controller = controller_bindings_.at(controller_index).at(input_index).is_held; + success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).is_held; } else { // El usuario quiere saber si ACABA de ser pulsada (evento de un solo fotograma) - success_controller = controller_bindings_.at(controller_index).at(input_index).just_pressed; + success_controller = controller_bindings_.at(controller_index).at(INPUT_INDEX).just_pressed; } } } @@ -87,11 +87,11 @@ bool Input::checkInput(InputAction input, bool repeat, InputDevice device, int c // Comprueba si hay almenos un input activo bool Input::checkAnyInput(InputDevice device, int controller_index) { // Obtenemos el número total de acciones posibles para iterar sobre ellas. - const int num_actions = static_cast(InputAction::SIZE); + const int NUM_ACTIONS = static_cast(InputAction::SIZE); // --- Comprobación del Teclado --- if (device == InputDevice::KEYBOARD || device == InputDevice::ANY) { - for (int i = 0; i < num_actions; ++i) { + for (int i = 0; i < NUM_ACTIONS; ++i) { // Simplemente leemos el estado pre-calculado por Input::update(). // Ya no se llama a SDL_GetKeyboardState ni se modifica el estado '.active'. if (key_bindings_.at(i).just_pressed) { @@ -105,7 +105,7 @@ bool Input::checkAnyInput(InputDevice device, int controller_index) { if (gameControllerFound() && controller_index >= 0 && controller_index < num_gamepads_) { if (device == InputDevice::CONTROLLER || device == InputDevice::ANY) { // Bucle CORREGIDO: Iteramos sobre todas las acciones, no sobre el número de mandos. - for (int i = 0; i < num_actions; ++i) { + for (int i = 0; i < NUM_ACTIONS; ++i) { // Leemos el estado pre-calculado para el mando y la acción específicos. if (controller_bindings_.at(controller_index).at(i).just_pressed) { return true; // Se encontró una acción recién pulsada en el mando. @@ -277,15 +277,15 @@ std::string Input::inputToString(InputAction input) const { // Convierte un std::string a InputAction InputAction Input::stringToInput(const std::string &name) const { - static const std::unordered_map inputMap = { + static const std::unordered_map INPUT_MAP = { {"input_fire_left", InputAction::FIRE_LEFT}, {"input_fire_center", InputAction::FIRE_CENTER}, {"input_fire_right", InputAction::FIRE_RIGHT}, {"input_start", InputAction::START}, {"input_service", InputAction::SERVICE}}; - auto it = inputMap.find(name); - return it != inputMap.end() ? it->second : InputAction::NONE; + auto it = INPUT_MAP.find(name); + return it != INPUT_MAP.end() ? it->second : InputAction::NONE; } // Comprueba el eje del mando diff --git a/source/item.cpp b/source/item.cpp index 7416b24..77b3b0f 100644 --- a/source/item.cpp +++ b/source/item.cpp @@ -44,13 +44,13 @@ Item::Item(ItemType type, float x, float y, SDL_FRect &play_area, std::shared_pt } void Item::alignTo(int x) { - const float min_x = param.game.play_area.rect.x + 1; - const float max_x = play_area_.w - width_ - 1; + const float MIN_X = param.game.play_area.rect.x + 1; + const float MAX_X = play_area_.w - width_ - 1; pos_x_ = x - (width_ / 2); // Ajusta para que no quede fuera de la zona de juego - pos_x_ = std::clamp(pos_x_, min_x, max_x); + pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X); // Actualiza el sprite shiftSprite(); diff --git a/source/notifier.cpp b/source/notifier.cpp index d0516eb..b89e2de 100644 --- a/source/notifier.cpp +++ b/source/notifier.cpp @@ -66,15 +66,15 @@ void Notifier::update() { // Comprueba los estados if (notifications_[i].state == NotificationStatus::RISING) { - const float step = ((float)notifications_[i].counter / notifications_[i].travel_dist); - const int alpha = 255 * step; + const float STEP = ((float)notifications_[i].counter / notifications_[i].travel_dist); + const int ALPHA = 255 * STEP; if (param.notification.pos_v == NotifyPosition::TOP) { notifications_[i].rect.y++; } else { notifications_[i].rect.y--; } - notifications_[i].texture->setAlpha(alpha); + notifications_[i].texture->setAlpha(ALPHA); if (notifications_[i].rect.y == notifications_[i].y) { notifications_[i].state = NotificationStatus::STAY; @@ -89,15 +89,15 @@ void Notifier::update() { notifications_[i].counter = 0; } } else if (notifications_[i].state == NotificationStatus::VANISHING) { - const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist); - const int alpha = 255 * (1 - step); + const float STEP = (notifications_[i].counter / (float)notifications_[i].travel_dist); + const int ALPHA = 255 * (1 - STEP); if (param.notification.pos_v == NotifyPosition::TOP) { notifications_[i].rect.y--; } else { notifications_[i].rect.y++; } - notifications_[i].texture->setAlpha(alpha); + notifications_[i].texture->setAlpha(ALPHA); if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist) { notifications_[i].state = NotificationStatus::FINISHED; @@ -176,7 +176,7 @@ void Notifier::show(std::vector texts, int icon, const std::string // Offset const auto TRAVEL_DIST = HEIGHT + PADDING_OUT; - auto OFFSET = notifications_.empty() + auto offset = notifications_.empty() ? DESP_V : notifications_.back().y + (param.notification.pos_v == NotifyPosition::TOP ? TRAVEL_DIST : -TRAVEL_DIST); @@ -185,11 +185,11 @@ void Notifier::show(std::vector texts, int icon, const std::string // Inicializa variables n.code = code; - n.y = OFFSET; + n.y = offset; n.travel_dist = TRAVEL_DIST; n.texts = texts; n.shape = SHAPE; - const float POS_Y = OFFSET + (param.notification.pos_v == NotifyPosition::TOP ? -TRAVEL_DIST : TRAVEL_DIST); + const float POS_Y = offset + (param.notification.pos_v == NotifyPosition::TOP ? -TRAVEL_DIST : TRAVEL_DIST); n.rect = {desp_h, POS_Y, WIDTH, HEIGHT}; // Crea la textura @@ -234,10 +234,10 @@ void Notifier::show(std::vector texts, int icon, const std::string } // Escribe el texto de la notificación - const Color color{255, 255, 255}; + const Color COLOR{255, 255, 255}; int iterator = 0; for (const auto &text : texts) { - text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, color); + text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, COLOR); ++iterator; } diff --git a/source/path_sprite.cpp b/source/path_sprite.cpp index bd7ed33..2a5cd7d 100644 --- a/source/path_sprite.cpp +++ b/source/path_sprite.cpp @@ -6,16 +6,16 @@ #include // Para move // Devuelve un vector con los puntos que conforman la ruta -std::vector createPath(float start, float end, PathType type, float fixed_pos, int steps, const std::function &easingFunction) { +std::vector createPath(float start, float end, PathType type, float fixed_pos, int steps, const std::function &easing_function) { std::vector v; v.reserve(steps); for (int i = 0; i < steps; ++i) { double t = static_cast(i) / (steps - 1); - double value = start + (end - start) * easingFunction(t); + double value = start + (end - start) * easing_function(t); if ((start > 0 && end < 0) || (start < 0 && end > 0)) { - value = start + (end > 0 ? 1 : -1) * std::abs(end - start) * easingFunction(t); + value = start + (end > 0 ? 1 : -1) * std::abs(end - start) * easing_function(t); } switch (type) { @@ -56,16 +56,16 @@ void PathSprite::addPath(Path path, bool centered) { switch (path_centered) { case PathCentered::ON_X: { - const int x = path.spots.back().x - pos_.w / 2; + const int X = path.spots.back().x - pos_.w / 2; for (auto &spot : path.spots) - spot.x = x; + spot.x = X; paths_.emplace_back(path); break; } case PathCentered::ON_Y: { - const int y = path.spots.back().y - pos_.h / 2; + const int Y = path.spots.back().y - pos_.h / 2; for (auto &spot : path.spots) - spot.y = y; + spot.y = Y; paths_.emplace_back(path); break; } @@ -76,8 +76,8 @@ void PathSprite::addPath(Path path, bool centered) { } // Añade un recorrido -void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easingFunction, int waiting_counter) { - paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easingFunction), waiting_counter); +void PathSprite::addPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function &easing_function, int waiting_counter) { + paths_.emplace_back(createPath(start, end, type, fixed_pos, steps, easing_function), waiting_counter); } // Añade un recorrido @@ -95,8 +95,8 @@ void PathSprite::enable() { // Establece la posición auto &path = paths_.at(current_path_); - const auto &P = path.spots.at(path.counter); - setPosition(P); + const auto &p = path.spots.at(path.counter); + setPosition(p); } // Coloca el sprite en los diferentes puntos del recorrido diff --git a/source/player.cpp b/source/player.cpp index 187dc73..8c6e687 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -174,8 +174,8 @@ void Player::move() { if (player_sprite_->getPosY() > play_area_.h - HEIGHT_) { if (player_sprite_->getVelY() < 2.0f) { // Si la velocidad de rebote es baja, lo detiene y cambia de estado - const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE; - demo_ ? setPlayingState(PlayerState::LYING_ON_THE_FLOOR_FOREVER) : setPlayingState(nextPlayerStatus); + const auto NEXT_PLAYER_STATUS = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE; + demo_ ? setPlayingState(PlayerState::LYING_ON_THE_FLOOR_FOREVER) : setPlayingState(NEXT_PLAYER_STATUS); pos_x_ = player_sprite_->getPosX(); pos_y_ = default_pos_y_; player_sprite_->clear(); @@ -791,14 +791,14 @@ void Player::playSound(const std::string &name) { if (demo_) return; - static auto audio = Audio::get(); - audio->playSound(name); + static auto audio_ = Audio::get(); + audio_->playSound(name); } // Añade una puntuación a la tabla de records void Player::addScoreToScoreBoard() { - const auto entry = HiScoreEntry(trim(getLastEnterName()), getScore(), get1CC()); + const auto ENTRY = HiScoreEntry(trim(getLastEnterName()), getScore(), get1CC()); auto manager = std::make_unique(Options::settings.hi_score_table); - Options::settings.last_hi_score_entry.at(getId() - 1) = manager->add(entry); + Options::settings.last_hi_score_entry.at(getId() - 1) = manager->add(ENTRY); manager->saveToFile(Asset::get()->get("score.bin")); } \ No newline at end of file diff --git a/source/resource.cpp b/source/resource.cpp index 0c74270..faba793 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -234,9 +234,9 @@ void Resource::loadAnimations() { void Resource::loadDemoData() { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES"); - constexpr std::array demo_files = {"demo1.bin", "demo2.bin"}; + constexpr std::array DEMO_FILES = {"demo1.bin", "demo2.bin"}; - for (const auto &file : demo_files) { + for (const auto &file : DEMO_FILES) { updateLoadingProgress(file); demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get(file))); } @@ -286,7 +286,7 @@ void Resource::createTextures() { } // Texturas de tamaño doble - std::vector strings2X = { + std::vector strings2_x = { {"game_text_100000_points", "100.000"}, {"game_text_get_ready", Lang::getText("[GAME_TEXT] 7")}, {"game_text_last_stage", Lang::getText("[GAME_TEXT] 3")}, @@ -294,7 +294,7 @@ void Resource::createTextures() { {"game_text_game_over", "Game Over"}}; auto text2 = getText("04b_25_2x"); - for (const auto &s : strings2X) { + for (const auto &s : strings2_x) { textures_.emplace_back(Resource::ResourceTexture(s.name, text2->writeToTexture(s.text, 1, -4))); printWithDots("Texture : ", s.name, "[ DONE ]"); } @@ -304,11 +304,11 @@ void Resource::createTextures() { void Resource::createText() { struct ResourceInfo { std::string key; - std::string textureFile; - std::string textFile; + std::string texture_file; + std::string text_file; - ResourceInfo(const std::string &k, const std::string &tFile, const std::string &txtFile) - : key(k), textureFile(tFile), textFile(txtFile) {} + ResourceInfo(const std::string &k, const std::string &t_file, const std::string &txt_file) + : key(k), texture_file(t_file), text_file(txt_file) {} }; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> CREATING TEXT OBJECTS"); @@ -328,7 +328,7 @@ void Resource::createText() { {"smb2_grad", "smb2_grad.png", "smb2.txt"}}; for (const auto &resource : resources) { - texts_.emplace_back(Resource::ResourceText(resource.key, std::make_shared(getTexture(resource.textureFile), getTextFile(resource.textFile)))); + texts_.emplace_back(Resource::ResourceText(resource.key, std::make_shared(getTexture(resource.texture_file), getTextFile(resource.text_file)))); printWithDots("Text : ", resource.key, "[ DONE ]"); } } diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 693a6b7..8ba790e 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -213,8 +213,8 @@ void Scoreboard::fillPanelTextures() { // HI-SCORE text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"), 1, text_color1_); - const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - "; - text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_), 1, text_color2_); + const std::string NAME = hi_score_name_ == "" ? "" : hi_score_name_ + " - "; + text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, NAME + updateScoreText(hi_score_), 1, text_color2_); break; } @@ -242,18 +242,18 @@ void Scoreboard::fillPanelTextures() { // Recorre todos los slots de letras del nombre for (size_t j = 0; j < NAME_SIZE; ++j) { // Selecciona el color - const Color color = j < selector_pos_[i] ? text_color2_ : text_color1_; + const Color COLOR = j < selector_pos_[i] ? text_color2_ : text_color1_; if (j != selector_pos_[i] || time_counter_ % 3 == 0) { // Dibuja la linea if (j >= selector_pos_[i]) { - SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255); + SDL_SetRenderDrawColor(renderer_, COLOR.r, COLOR.g, COLOR.b, 255); SDL_RenderLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h); } // Dibuja la letra if (j < record_name_[i].size()) { - text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), color); + text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), COLOR); } } rect.x += 7; @@ -323,11 +323,11 @@ void Scoreboard::fillBackgroundTexture() { // Recalcula las anclas de los elementos void Scoreboard::recalculateAnchors() { // Recalcula la posición y el tamaño de los paneles - const float panel_width = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS; + const float PANEL_WIDTH = (float)rect_.w / (float)SCOREBOARD_MAX_PANELS; for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i) { - panel_[i].pos.x = roundf(panel_width * i); + panel_[i].pos.x = roundf(PANEL_WIDTH * i); panel_[i].pos.y = 0; - panel_[i].pos.w = roundf(panel_width * (i + 1)) - panel_[i].pos.x; + panel_[i].pos.w = roundf(PANEL_WIDTH * (i + 1)) - panel_[i].pos.x; panel_[i].pos.h = rect_.h; } @@ -342,7 +342,7 @@ void Scoreboard::recalculateAnchors() { const float ROW4 = 1 + (ROW_SIZE * 3) + (TEXT_HEIGHT / 2) - 3; // Columna - const float COL = panel_width / 2; + const float COL = PANEL_WIDTH / 2; // Slots de 4 slot4_1_ = {COL, ROW1}; @@ -351,8 +351,8 @@ void Scoreboard::recalculateAnchors() { slot4_4_ = {COL, ROW4}; // Primer cuadrado para poner el nombre de record - const int enter_name_lenght = text_scoreboard_->lenght(std::string(NAME_SIZE, 'A')); - enter_name_pos_.x = COL - (enter_name_lenght / 2); + const int ENTER_NAME_LENGHT = text_scoreboard_->lenght(std::string(NAME_SIZE, 'A')); + enter_name_pos_.x = COL - (ENTER_NAME_LENGHT / 2); enter_name_pos_.y = ROW4; // Recoloca los sprites diff --git a/source/sections/credits.cpp b/source/sections/credits.cpp index 3d3ad69..2a64fa6 100644 --- a/source/sections/credits.cpp +++ b/source/sections/credits.cpp @@ -257,8 +257,8 @@ void Credits::fillCanvas() { // Dibuja el rectangulo rojo // 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); + const Color COLOR = color_.LIGHTEN(); + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), COLOR.r, COLOR.g, COLOR.b, 0xFF); SDL_RenderRect(Screen::get()->getRenderer(), &red_rect); // Si el mini_logo está en su destino, lo dibuja encima de lo anterior @@ -305,19 +305,19 @@ void Credits::updateTextureDstRects() { // Tira globos al escenario void Credits::throwBalloons() { - constexpr int speed = 200; - const std::vector sets = {0, 63, 25, 67, 17, 75, 13, 50}; + constexpr int SPEED = 200; + const std::vector SETS = {0, 63, 25, 67, 17, 75, 13, 50}; - if (counter_ > ((sets.size() - 1) * speed) * 3) { + if (counter_ > ((SETS.size() - 1) * SPEED) * 3) { return; } - if (counter_ % speed == 0) { - const int index = (counter_ / speed) % sets.size(); - balloon_manager_->deploySet(sets.at(index), -60); + if (counter_ % SPEED == 0) { + const int INDEX = (counter_ / SPEED) % SETS.size(); + balloon_manager_->deploySet(SETS.at(INDEX), -60); } - if (counter_ % (speed * 4) == 0 && counter_ > 0) { + if (counter_ % (SPEED * 4) == 0 && counter_ > 0) { balloon_manager_->createPowerBall(); } } @@ -365,7 +365,7 @@ void Credits::initPlayers() { // Actualiza los rectangulos negros void Credits::updateBlackRects() { - static int current_step = steps_; + static int current_step_ = steps_; if (top_black_rect_.h != param.game.game_area.center_y - 1 && bottom_black_rect_.y != param.game.game_area.center_y + 1) { // Si los rectangulos superior e inferior no han llegado al centro if (counter_ % 4 == 0) { @@ -376,8 +376,8 @@ void Credits::updateBlackRects() { ++bottom_black_rect_.h; bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1, param.game.game_area.center_y + 1); - --current_step; - setVolume(static_cast(initial_volume_ * current_step / steps_)); + --current_step_; + setVolume(static_cast(initial_volume_ * current_step_ / steps_)); } } else { // Si los rectangulos superior e inferior han llegado al centro @@ -391,8 +391,8 @@ void Credits::updateBlackRects() { right_black_rect_.w += SPEED; right_black_rect_.x = std::max(right_black_rect_.x - SPEED, param.game.game_area.center_x); - --current_step; - setVolume(static_cast(initial_volume_ * current_step / steps_)); + --current_step_; + setVolume(static_cast(initial_volume_ * current_step_ / steps_)); } else { // Si los rectangulos izquierdo y derecho han llegado al centro setVolume(0); @@ -452,33 +452,33 @@ void Credits::cycleColors() { constexpr int UPPER_LIMIT = 140; // Límite superior constexpr int LOWER_LIMIT = 30; // Límite inferior - static float r = static_cast(UPPER_LIMIT); - static float g = static_cast(LOWER_LIMIT); - static float b = static_cast(LOWER_LIMIT); - static float stepR = -0.5f; // Paso flotante para transiciones suaves - static float stepG = 0.3f; - static float stepB = 0.1f; + static float r_ = static_cast(UPPER_LIMIT); + static float g_ = static_cast(LOWER_LIMIT); + static float b_ = static_cast(LOWER_LIMIT); + static float step_r_ = -0.5f; // Paso flotante para transiciones suaves + static float step_g_ = 0.3f; + static float step_b_ = 0.1f; // Ajustar valores de R - r += stepR; - if (r >= UPPER_LIMIT || r <= LOWER_LIMIT) { - stepR = -stepR; // Cambia de dirección al alcanzar los límites + r_ += step_r_; + if (r_ >= UPPER_LIMIT || r_ <= LOWER_LIMIT) { + step_r_ = -step_r_; // Cambia de dirección al alcanzar los límites } // Ajustar valores de G - g += stepG; - if (g >= UPPER_LIMIT || g <= LOWER_LIMIT) { - stepG = -stepG; // Cambia de dirección al alcanzar los límites + g_ += step_g_; + if (g_ >= UPPER_LIMIT || g_ <= LOWER_LIMIT) { + step_g_ = -step_g_; // Cambia de dirección al alcanzar los límites } // Ajustar valores de B - b += stepB; - if (b >= UPPER_LIMIT || b <= LOWER_LIMIT) { - stepB = -stepB; // Cambia de dirección al alcanzar los límites + b_ += step_b_; + if (b_ >= UPPER_LIMIT || b_ <= LOWER_LIMIT) { + step_b_ = -step_b_; // Cambia de dirección al alcanzar los límites } // Aplicar el color, redondeando a enteros antes de usar - color_ = Color(static_cast(r), static_cast(g), static_cast(b)); + color_ = Color(static_cast(r_), static_cast(g_), static_cast(b_)); tiled_bg_->setColor(color_); } diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 780fe21..d23c8f9 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -253,8 +253,8 @@ void Game::updateStage() { createMessage(paths, Resource::get()->getTexture("game_text_last_stage")); } else { auto text = Resource::get()->getText("04b_25_2x"); - const std::string caption = std::to_string(10 - Stage::number) + Lang::getText("[GAME_TEXT] 2"); - createMessage(paths, text->writeToTexture(caption, 1, -4)); + const std::string CAPTION = std::to_string(10 - Stage::number) + Lang::getText("[GAME_TEXT] 2"); + createMessage(paths, text->writeToTexture(CAPTION, 1, -4)); } } @@ -422,48 +422,48 @@ void Game::checkPlayerItemCollision(std::shared_ptr &player) { switch (item->getType()) { case ItemType::DISK: { player->addScore(1000); - const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2; - createItemText(x, game_text_textures_.at(0)); + 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); - const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2; - createItemText(x, game_text_textures_.at(1)); + 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); - const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2; - createItemText(x, game_text_textures_.at(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); - const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2; - createItemText(x, game_text_textures_.at(6)); + 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; - createItemText(x, game_text_textures_.at(5)); + 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; } case ItemType::COFFEE: { if (player->getCoffees() == 2) { player->addScore(5000); - const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2; - createItemText(x, game_text_textures_.at(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; - createItemText(x, game_text_textures_.at(4)); + 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"); break; @@ -471,8 +471,8 @@ void Game::checkPlayerItemCollision(std::shared_ptr &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; - createItemText(x, game_text_textures_.at(3)); + 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; } @@ -516,12 +516,12 @@ void Game::checkBulletCollision() { auto player = getPlayer(bullet->getOwner()); // Suelta el item si se da el caso - const auto dropped_item = dropItem(); - if (dropped_item != ItemType::NONE && !demo_.recording) { - if (dropped_item != ItemType::COFFEE_MACHINE) { - createItem(dropped_item, balloon->getPosX(), balloon->getPosY()); + const auto DROPPED_ITEM = dropItem(); + if (DROPPED_ITEM != ItemType::NONE && !demo_.recording) { + if (DROPPED_ITEM != ItemType::COFFEE_MACHINE) { + createItem(DROPPED_ITEM, balloon->getPosX(), balloon->getPosY()); } else { - createItem(dropped_item, player->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT); + createItem(DROPPED_ITEM, player->getPosX(), param.game.game_area.rect.y - Item::COFFEE_MACHINE_HEIGHT); coffee_machine_enabled_ = true; } } @@ -595,32 +595,32 @@ void Game::renderItems() { // Devuelve un item al azar y luego segun sus probabilidades ItemType Game::dropItem() { - const auto lucky_number = rand() % 100; - const auto item = rand() % 6; + const auto LUCKY_NUMBER = rand() % 100; + const auto ITEM = rand() % 6; - switch (item) { + switch (ITEM) { case 0: - if (lucky_number < helper_.item_disk_odds) { + if (LUCKY_NUMBER < helper_.item_disk_odds) { return ItemType::DISK; } break; case 1: - if (lucky_number < helper_.item_gavina_odds) { + if (LUCKY_NUMBER < helper_.item_gavina_odds) { return ItemType::GAVINA; } break; case 2: - if (lucky_number < helper_.item_pacmar_odds) { + if (LUCKY_NUMBER < helper_.item_pacmar_odds) { return ItemType::GAVINA; } break; case 3: - if (lucky_number < helper_.item_clock_odds) { + if (LUCKY_NUMBER < helper_.item_clock_odds) { return ItemType::CLOCK; } break; case 4: - if (lucky_number < helper_.item_coffee_odds) { + if (LUCKY_NUMBER < helper_.item_coffee_odds) { helper_.item_coffee_odds = ITEM_COFFEE_ODDS_; return ItemType::COFFEE; } else { @@ -630,7 +630,7 @@ ItemType Game::dropItem() { } break; case 5: - if (lucky_number < helper_.item_coffee_machine_odds) { + if (LUCKY_NUMBER < helper_.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; @@ -666,22 +666,22 @@ void Game::freeItems() { void Game::createItemText(int x, std::shared_ptr texture) { path_sprites_.emplace_back(std::make_unique(texture)); - const auto w = texture->getWidth(); - const auto h = texture->getHeight(); + const auto W = texture->getWidth(); + const auto H = texture->getHeight(); - const int y0 = param.game.play_area.rect.h - h; - const int y1 = 160 - (h / 2); - const int y2 = -h; + const int Y0 = param.game.play_area.rect.h - H; + const int Y1 = 160 - (H / 2); + const int Y2 = -H; // Ajusta para que no se dibuje fuera de pantalla - x = std::clamp(x, 2, static_cast(param.game.play_area.rect.w) - w - 2); + x = std::clamp(x, 2, static_cast(param.game.play_area.rect.w) - W - 2); // Inicializa - path_sprites_.back()->setWidth(w); - path_sprites_.back()->setHeight(h); - path_sprites_.back()->setSpriteClip({0, 0, static_cast(w), static_cast(h)}); - path_sprites_.back()->addPath(y0, y1, PathType::VERTICAL, x, 100, easeOutQuint, 0); - path_sprites_.back()->addPath(y1, y2, PathType::VERTICAL, x, 80, easeInQuint, 0); + path_sprites_.back()->setWidth(W); + path_sprites_.back()->setHeight(H); + path_sprites_.back()->setSpriteClip({0, 0, static_cast(W), static_cast(H)}); + path_sprites_.back()->addPath(Y0, Y1, PathType::VERTICAL, x, 100, easeOutQuint, 0); + path_sprites_.back()->addPath(Y1, Y2, PathType::VERTICAL, x, 80, easeInQuint, 0); path_sprites_.back()->enable(); } @@ -866,19 +866,19 @@ void Game::updateBackground() { // Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego constexpr float CLOUDS_INITIAL_SPEED = 0.05f; constexpr float CLOUDS_FINAL_SPEED = 2.00f - CLOUDS_INITIAL_SPEED; - const float cloudsSpeed = (-CLOUDS_INITIAL_SPEED) + (-CLOUDS_FINAL_SPEED * (static_cast(Stage::total_power) / total_power_to_complete_game_)); - background_->setCloudsSpeed(cloudsSpeed); + const float CLOUDS_SPEED = (-CLOUDS_INITIAL_SPEED) + (-CLOUDS_FINAL_SPEED * (static_cast(Stage::total_power) / total_power_to_complete_game_)); + background_->setCloudsSpeed(CLOUDS_SPEED); // Calcula la transición de los diferentes fondos - constexpr float num = 1525.0f; // total_power_to_complete div 4 - const float gradient_number = std::min(Stage::total_power / num, 3.0f); - const float percent = gradient_number - static_cast(gradient_number); - background_->setGradientNumber(static_cast(gradient_number)); - background_->setTransition(percent); + constexpr float NUM = 1525.0f; // total_power_to_complete div 4 + const float GRADIENT_NUMBER = std::min(Stage::total_power / NUM, 3.0f); + const float PERCENT = GRADIENT_NUMBER - static_cast(GRADIENT_NUMBER); + background_->setGradientNumber(static_cast(GRADIENT_NUMBER)); + background_->setTransition(PERCENT); // Calcula la posición del sol - constexpr float sun_final_power = num * 2; - background_->setSunProgression(Stage::total_power / sun_final_power); + constexpr float SUN_FINAL_POWER = NUM * 2; + background_->setSunProgression(Stage::total_power / SUN_FINAL_POWER); background_->setMoonProgression(Stage::total_power / static_cast(total_power_to_complete_game_)); // Actualiza el objeto @@ -955,51 +955,51 @@ void Game::initPaths() { // Recorrido para el texto de "Get Ready!" (0,1) { 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 x2 = param.game.play_area.rect.w; - const int y = param.game.play_area.center_y; - paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 20)); - paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0)); + const auto W = texture->getWidth(); + const int X0 = -W; + 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(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 20)); + paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0)); } // Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3) { 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 y2 = -h; - const int x = param.game.play_area.center_x; - paths_.emplace_back(Path(createPath(y0, y1, PathType::VERTICAL, x, 80, easeOutQuint), 20)); - paths_.emplace_back(Path(createPath(y1, y2, PathType::VERTICAL, x, 80, easeInQuint), 0)); + 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 Y2 = -H; + const int X = param.game.play_area.center_x; + paths_.emplace_back(Path(createPath(Y0, Y1, PathType::VERTICAL, X, 80, easeOutQuint), 20)); + paths_.emplace_back(Path(createPath(Y1, Y2, PathType::VERTICAL, X, 80, easeInQuint), 0)); } // Recorrido para el texto de "Congratulations!!" (3,4) { const auto &texture = Resource::get()->getTexture("game_text_congratulations"); - 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 x2 = param.game.play_area.rect.w; - const int y = param.game.play_area.center_y - h / 2 - 20; - paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400)); - paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0)); + 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 X2 = param.game.play_area.rect.w; + const int Y = param.game.play_area.center_y - H / 2 - 20; + paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400)); + paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0)); } // Recorrido para el texto de "1.000.000 points!" (5,6) { const auto &texture = Resource::get()->getTexture("game_text_1000000_points"); - 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 x2 = -w; - const int y = param.game.play_area.center_y + h / 2 - 20; - paths_.emplace_back(Path(createPath(x0, x1, PathType::HORIZONTAL, y, 80, easeOutQuint), 400)); - paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0)); + 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 X2 = -W; + const int Y = param.game.play_area.center_y + H / 2 - 20; + paths_.emplace_back(Path(createPath(X0, X1, PathType::HORIZONTAL, Y, 80, easeOutQuint), 400)); + paths_.emplace_back(Path(createPath(X1, X2, PathType::HORIZONTAL, Y, 80, easeInQuint), 0)); } } @@ -1097,17 +1097,17 @@ void Game::pause(bool value) { // Añade una puntuación a la tabla de records void Game::addScoreToScoreBoard(const std::shared_ptr &player) { - const auto entry = HiScoreEntry(trim(player->getLastEnterName()), player->getScore(), player->get1CC()); + const auto ENTRY = HiScoreEntry(trim(player->getLastEnterName()), player->getScore(), player->get1CC()); auto manager = std::make_unique(Options::settings.hi_score_table); - Options::settings.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry); + Options::settings.last_hi_score_entry.at(player->getId() - 1) = manager->add(ENTRY); manager->saveToFile(Asset::get()->get("score.bin")); hi_score_.name = Options::settings.hi_score_table.front().name; } // Saca del estado de GAME OVER al jugador si el otro está activo -void Game::checkAndUpdatePlayerStatus(int activePlayerIndex, int inactivePlayerIndex) { - if (players_[activePlayerIndex]->isGameOver() && !players_[inactivePlayerIndex]->isGameOver() && !players_[inactivePlayerIndex]->isWaiting()) { - players_[activePlayerIndex]->setPlayingState(PlayerState::WAITING); +void Game::checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index) { + if (players_[active_player_index]->isGameOver() && !players_[inactive_player_index]->isGameOver() && !players_[inactive_player_index]->isWaiting()) { + players_[active_player_index]->setPlayingState(PlayerState::WAITING); } } @@ -1210,21 +1210,21 @@ void Game::DEMO_handleInput() { // Procesa las entradas para un jugador específico durante el modo demo. void Game::DEMO_handlePlayerInput(const std::shared_ptr &player, int index) { - const auto &demoData = demo_.data[index][demo_.counter]; + const auto &demo_data = demo_.data[index][demo_.counter]; - if (demoData.left == 1) { + if (demo_data.left == 1) { player->setInput(InputAction::LEFT); - } else if (demoData.right == 1) { + } else if (demo_data.right == 1) { player->setInput(InputAction::RIGHT); - } else if (demoData.no_input == 1) { + } else if (demo_data.no_input == 1) { player->setInput(InputAction::NONE); } - if (demoData.fire == 1) { + if (demo_data.fire == 1) { handleFireInput(player, BulletType::UP); - } else if (demoData.fire_left == 1) { + } else if (demo_data.fire_left == 1) { handleFireInput(player, BulletType::LEFT); - } else if (demoData.fire_right == 1) { + } else if (demo_data.fire_right == 1) { handleFireInput(player, BulletType::RIGHT); } } @@ -1275,31 +1275,31 @@ void Game::handleFireInput(const std::shared_ptr &player, BulletType bul // Gestiona las entradas de todos los jugadores en el modo normal (fuera del modo demo). void Game::handlePlayersInput() { - for (const auto &PLAYER : players_) { - if (PLAYER->isPlaying()) { + for (const auto &player : players_) { + if (player->isPlaying()) { // Maneja el input de los jugadores en modo normal. - handleNormalPlayerInput(PLAYER); - } else if (PLAYER->isContinue() || PLAYER->isWaiting()) { + handleNormalPlayerInput(player); + } else if (player->isContinue() || player->isWaiting()) { // Gestiona la continuación del jugador. - handlePlayerContinue(PLAYER); - } else if (PLAYER->isEnteringName() || PLAYER->isEnteringNameGameCompleted() || PLAYER->isShowingName()) { + handlePlayerContinue(player); + } else if (player->isEnteringName() || player->isEnteringNameGameCompleted() || player->isShowingName()) { // Gestiona la introducción del nombre del jugador. - handleNameInput(PLAYER); + handleNameInput(player); } } } // Maneja las entradas de movimiento y disparo para un jugador en modo normal. void Game::handleNormalPlayerInput(const std::shared_ptr &player) { - const auto &CONTROLLER = Options::controllers.at(player->getController()); + const auto &controller = Options::controllers.at(player->getController()); const bool AUTOFIRE = player->isPowerUp() || Options::settings.autofire; - if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) { + if (input_->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) { player->setInput(InputAction::LEFT); #ifdef RECORDING demo_.keys.left = 1; #endif - } else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) { + } else if (input_->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, controller.type, controller.index)) { player->setInput(InputAction::RIGHT); #ifdef RECORDING demo_.keys.right = 1; @@ -1315,18 +1315,18 @@ void Game::handleNormalPlayerInput(const std::shared_ptr &player) { } // Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado. -void Game::handleFireInputs(const std::shared_ptr &player, bool autofire, int controllerIndex) { - if (input_->checkInput(InputAction::FIRE_CENTER, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { +void Game::handleFireInputs(const std::shared_ptr &player, bool autofire, int controller_index) { + if (input_->checkInput(InputAction::FIRE_CENTER, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) { handleFireInput(player, BulletType::UP); #ifdef RECORDING demo_.keys.fire = 1; #endif - } else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::FIRE_LEFT, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) { handleFireInput(player, BulletType::LEFT); #ifdef RECORDING demo_.keys.fire_left = 1; #endif - } else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::FIRE_RIGHT, autofire, Options::controllers[controller_index].type, Options::controllers[controller_index].index)) { handleFireInput(player, BulletType::RIGHT); #ifdef RECORDING demo_.keys.fire_right = 1; @@ -1336,15 +1336,15 @@ void Game::handleFireInputs(const std::shared_ptr &player, bool autofire // Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio. void Game::handlePlayerContinue(const std::shared_ptr &player) { - const auto controllerIndex = player->getController(); - if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + const auto CONTROLLER_INDEX = player->getController(); + if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { player->setPlayingState(PlayerState::RESPAWNING); } // Disminuye el contador de continuación si se presiona cualquier botón de disparo. - if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) || - input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) || - input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) || + input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) || + input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { if (player->getContinueCounter() < param.scoreboard.skip_countdown_value) { player->decContinueCounter(); } @@ -1353,8 +1353,8 @@ void Game::handlePlayerContinue(const std::shared_ptr &player) { // Procesa las entradas para la introducción del nombre del jugador. void Game::handleNameInput(const std::shared_ptr &player) { - const auto controllerIndex = player->getController(); - if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + const auto CONTROLLER_INDEX = player->getController(); + if (input_->checkInput(InputAction::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { if (player->isShowingName()) { player->setPlayingState(PlayerState::CONTINUE); } else if (player->getEnterNamePositionOverflow()) { @@ -1364,18 +1364,18 @@ void Game::handleNameInput(const std::shared_ptr &player) { } else { player->setInput(InputAction::RIGHT); } - } else if (input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index) || - input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index) || + input_->checkInput(InputAction::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { if (player->isShowingName()) { player->setPlayingState(PlayerState::CONTINUE); } else { player->setInput(InputAction::LEFT); } - } else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { player->setInput(InputAction::UP); - } else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { player->setInput(InputAction::DOWN); - } else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[controllerIndex].type, Options::controllers[controllerIndex].index)) { + } else if (input_->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, Options::controllers[CONTROLLER_INDEX].type, Options::controllers[CONTROLLER_INDEX].index)) { if (player->isShowingName()) { player->setPlayingState(PlayerState::CONTINUE); } else { @@ -1666,12 +1666,12 @@ void Game::cleanVectors() { // Gestiona el nivel de amenaza void Game::updateMenace() { if (state_ == GameState::PLAYING) { - const auto stage = Stage::get(Stage::number); - const float percent = Stage::power / stage.power_to_complete; - const int difference = stage.max_menace - stage.min_menace; + const auto STAGE = Stage::get(Stage::number); + const float PERCENT = Stage::power / STAGE.power_to_complete; + const int DIFFERENCE = STAGE.max_menace - STAGE.min_menace; // Aumenta el nivel de amenaza en función de la puntuación - menace_threshold_ = stage.min_menace + (difference * percent); + menace_threshold_ = STAGE.min_menace + (DIFFERENCE * PERCENT); // Si el nivel de amenza es inferior al umbral if (menace_current_ < menace_threshold_) { @@ -1694,11 +1694,11 @@ void Game::checkAndUpdateBalloonSpeed() { if (difficulty_ != Options::DifficultyCode::NORMAL) return; - const float percent = static_cast(Stage::power) / Stage::get(Stage::number).power_to_complete; - const float thresholds[] = {0.2f, 0.4f, 0.6f, 0.8f}; + const float PERCENT = static_cast(Stage::power) / Stage::get(Stage::number).power_to_complete; + const float THRESHOLDS[] = {0.2f, 0.4f, 0.6f, 0.8f}; - for (size_t i = 0; i < std::size(thresholds); ++i) { - if (balloon_manager_->getBalloonSpeed() == BALLOON_SPEED[i] && percent > thresholds[i]) { + for (size_t i = 0; i < std::size(THRESHOLDS); ++i) { + if (balloon_manager_->getBalloonSpeed() == BALLOON_SPEED[i] && PERCENT > THRESHOLDS[i]) { balloon_manager_->setBalloonSpeed(BALLOON_SPEED[i + 1]); break; // Salir del bucle una vez actualizada la velocidad y aplicada } @@ -1715,8 +1715,8 @@ void Game::playSound(const std::string &name) { if (demo_.enabled) return; - static auto audio = Audio::get(); - audio->playSound(name); + static auto audio_ = Audio::get(); + audio_->playSound(name); } // Organiza los jugadores para que los vivos se pinten sobre los muertos @@ -1727,9 +1727,9 @@ void Game::movePlayersToFront() { 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 dyingPlayer = *it; + std::shared_ptr dying_player = *it; players_.erase(it); - players_.insert(players_.begin(), dyingPlayer); + players_.insert(players_.begin(), dying_player); } } players_to_reorder.clear(); @@ -1740,21 +1740,21 @@ void Game::checkServiceMenu() { if (demo_.enabled) return; - static bool was_paused_before_service_menu = false; - static bool service_menu_was_active = false; + static bool was_paused_before_service_menu_ = false; + static bool service_menu_was_active_ = false; bool service_menu_is_active = ServiceMenu::get()->isEnabled(); - if (service_menu_is_active && !service_menu_was_active) { + if (service_menu_is_active && !service_menu_was_active_) { // El menú acaba de abrirse - was_paused_before_service_menu = paused_; + was_paused_before_service_menu_ = paused_; pause(true); - } else if (!service_menu_is_active && service_menu_was_active) { + } else if (!service_menu_is_active && service_menu_was_active_) { // El menú acaba de cerrarse - pause(was_paused_before_service_menu); + pause(was_paused_before_service_menu_); } - service_menu_was_active = service_menu_is_active; + service_menu_was_active_ = service_menu_is_active; } #ifdef DEBUG @@ -1770,9 +1770,9 @@ void Game::checkDebugEvents(const SDL_Event &event) { } case SDLK_2: // Activa o desactiva la aparición de globos { - static bool deploy_balloons = true; - deploy_balloons = !deploy_balloons; - balloon_manager_->enableBalloonDeployment(deploy_balloons); + static bool deploy_balloons_ = true; + deploy_balloons_ = !deploy_balloons_; + balloon_manager_->enableBalloonDeployment(deploy_balloons_); break; } case SDLK_3: // Activa el modo para pasar el juego automaticamente diff --git a/source/sections/hiscore_table.cpp b/source/sections/hiscore_table.cpp index 98bf818..d41bfc1 100644 --- a/source/sections/hiscore_table.cpp +++ b/source/sections/hiscore_table.cpp @@ -169,19 +169,19 @@ void HiScoreTable::updateFade() { // Convierte un entero a un string con separadores de miles std::string HiScoreTable::format(int number) { - const std::string separator = "."; - const std::string score = std::to_string(number); + const std::string SEPARATOR = "."; + const std::string SCORE = std::to_string(number); - auto index = (int)score.size() - 1; + auto index = (int)SCORE.size() - 1; std::string result; auto i = 0; while (index >= 0) { - result = score.at(index) + result; + result = SCORE.at(index) + result; index--; i++; if (i == 3) { i = 0; - result = separator + result; + result = SEPARATOR + result; } } @@ -200,44 +200,44 @@ void HiScoreTable::createSprites() { constexpr int ENTRY_LENGHT = 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 first_line = (param.game.height - size) / 2; + 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 FIRST_LINE = (param.game.height - SIZE) / 2; // Crea el sprite para el texto de cabecera header_ = std::make_unique(header_text->writeDXToTexture(TEXT_COLOR, Lang::getText("[HIGHSCORE_TABLE] CAPTION"), -2, background_fade_color_.INVERSE().LIGHTEN(25))); - header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line); + header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), FIRST_LINE); // Crea los sprites para las entradas en la tabla de puntuaciones - const int animation = rand() % 4; - const std::string sample_line(ENTRY_LENGHT + 3, ' '); - auto sample_entry = std::make_unique(entry_text->writeDXToTexture(TEXT_SHADOW, sample_line, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR)); - const auto entry_width = sample_entry->getWidth(); + const int ANIMATION = rand() % 4; + const std::string SAMPLE_LINE(ENTRY_LENGHT + 3, ' '); + auto sample_entry = std::make_unique(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 one_cc = Options::settings.hi_score_table.at(i).one_credit_complete ? " }" : ""; + 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 ? " }" : ""; std::string dots; - for (int j = 0; j < (int)num_dots; ++j) { + for (int j = 0; j < (int)NUM_DOTS; ++j) { dots = dots + "."; } - const auto line = table_position + Options::settings.hi_score_table.at(i).name + dots + score + one_cc; + const auto LINE = TABLE_POSITION + Options::settings.hi_score_table.at(i).name + dots + SCORE + ONE_CC; - entry_names_.emplace_back(std::make_shared(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR))); - const int default_pos_x = (backbuffer_width - entry_width) / 2; - const int pos_x = (i < 9) ? default_pos_x : default_pos_x - entry_text->getCharacterSize(); - const int pos_y = (i * space_between_lines) + first_line + space_between_header; - constexpr int steps = 80; - switch (animation) { + entry_names_.emplace_back(std::make_shared(entry_text->writeDXToTexture(TEXT_SHADOW, LINE, 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR))); + const int DEFAULT_POS_X = (backbuffer_width - ENTRY_WIDTH) / 2; + const int POS_X = (i < 9) ? DEFAULT_POS_X : DEFAULT_POS_X - entry_text->getCharacterSize(); + const int POS_Y = (i * SPACE_BETWEEN_LINES) + FIRST_LINE + SPACE_BETWEEN_HEADER; + constexpr int STEPS = 80; + switch (ANIMATION) { case 0: // Ambos lados alternativamente { if (i % 2 == 0) { - entry_names_.back()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); + entry_names_.back()->addPath(-entry_names_.back()->getWidth(), POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint); entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0); } else { - entry_names_.back()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); + entry_names_.back()->addPath(backbuffer_width, POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint); entry_names_.back()->setPosition(backbuffer_width, 0); } break; @@ -245,21 +245,21 @@ void HiScoreTable::createSprites() { case 1: // Entran por la izquierda { - entry_names_.back()->addPath(-entry_names_.back()->getWidth(), pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); + entry_names_.back()->addPath(-entry_names_.back()->getWidth(), POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint); entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0); break; } case 2: // Entran por la derecha { - entry_names_.back()->addPath(backbuffer_width, pos_x, PathType::HORIZONTAL, pos_y, steps, easeOutQuint); + entry_names_.back()->addPath(backbuffer_width, POS_X, PathType::HORIZONTAL, POS_Y, STEPS, easeOutQuint); entry_names_.back()->setPosition(backbuffer_width, 0); break; } case 3: // Entran desde la parte inferior { - entry_names_.back()->addPath(backbuffer_height, pos_y, PathType::VERTICAL, pos_x, steps, easeOutQuint); + entry_names_.back()->addPath(backbuffer_height, POS_Y, PathType::VERTICAL, POS_X, STEPS, easeOutQuint); entry_names_.back()->setPosition(0, backbuffer_height); } @@ -271,12 +271,12 @@ void HiScoreTable::createSprites() { // Actualiza las posiciones de los sprites de texto void HiScoreTable::updateSprites() { - constexpr int init_counter = 190; - const int counter_between_entries = 16; - if (counter_ >= init_counter) { - const int counter2 = counter_ - init_counter; - if (counter2 % counter_between_entries == 0) { - int index = counter2 / counter_between_entries; + constexpr int INIT_COUNTER = 190; + const int COUNTER_BETWEEN_ENTRIES = 16; + if (counter_ >= INIT_COUNTER) { + const int COUNTER2 = counter_ - INIT_COUNTER; + if (COUNTER2 % COUNTER_BETWEEN_ENTRIES == 0) { + int index = COUNTER2 / COUNTER_BETWEEN_ENTRIES; if (index < static_cast(entry_names_.size())) { entry_names_.at(index)->enable(); } @@ -303,8 +303,8 @@ void HiScoreTable::initBackground() { background_->setPos(param.game.game_area.rect); background_->setCloudsSpeed(-0.1f); - const int lucky = rand() % 3; - switch (lucky) { + const int LUCKY = rand() % 3; + switch (LUCKY) { case 0: // Fondo verde { background_->setGradientNumber(2); @@ -341,9 +341,9 @@ void HiScoreTable::initBackground() { } // Obtiene un color del vector de colores de entradas -Color HiScoreTable::getEntryColor(int counter_) { +Color HiScoreTable::getEntryColor(int counter) { int cycle_length = entry_colors_.size() * 2 - 2; - size_t n = counter_ % cycle_length; + size_t n = counter % cycle_length; size_t index; if (n < entry_colors_.size()) { @@ -366,10 +366,10 @@ void HiScoreTable::iniEntryColors() { // Hace brillar los nombres de la tabla de records void HiScoreTable::glowEntryNames() { - const Color entry_color = getEntryColor(counter_ / 5); + const Color ENTRY_COLOR = getEntryColor(counter_ / 5); for (const auto &entry_index : Options::settings.last_hi_score_entry) { if (entry_index != -1) { - entry_names_.at(entry_index)->getTexture()->setColor(entry_color); + entry_names_.at(entry_index)->getTexture()->setColor(ENTRY_COLOR); } } } diff --git a/source/sections/instructions.cpp b/source/sections/instructions.cpp index 5caac11..c843b7c 100644 --- a/source/sections/instructions.cpp +++ b/source/sections/instructions.cpp @@ -110,7 +110,7 @@ void Instructions::updateSprites() { // Rellena la textura de texto void Instructions::fillTexture() { - const int desp_x = param.game.item_size + 8; + const int DESP_X = param.game.item_size + 8; // Modifica el renderizador para pintar en la textura auto temp = SDL_GetRenderTarget(renderer_); @@ -121,19 +121,19 @@ void Instructions::fillTexture() { SDL_RenderClear(renderer_); // Constantes - constexpr int num_lines = 4; - constexpr int num_item_lines = 4; - constexpr int num_post_headers = 2; - constexpr int num_pre_headers = 1; + constexpr int NUM_LINES = 4; + constexpr int NUM_ITEM_LINES = 4; + constexpr int NUM_POST_HEADERS = 2; + constexpr int NUM_PRE_HEADERS = 1; - 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_item_lines = param.game.item_size + item_space_; - const int space_new_paragraph = space_between_lines * 0.5f; + 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_ITEM_LINES = param.game.item_size + 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 first_line = (param.game.height - size) / 2; + 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 int lenght = 0; @@ -144,39 +144,39 @@ void Instructions::fillTexture() { Lang::getText("[INSTRUCTIONS] 10"), Lang::getText("[INSTRUCTIONS] 11")}; for (const auto &desc : ITEM_DESCRIPTIONS) { - const int l = text_->lenght(desc); - lenght = l > lenght ? l : lenght; + const int L = text_->lenght(desc); + lenght = L > lenght ? L : lenght; } - const int ANCHOR_ITEM = (param.game.width - (lenght + desp_x)) / 2; + const int ANCHOR_ITEM = (param.game.width - (lenght + DESP_X)) / 2; constexpr Color ORANGE_COLOR = Color(0XFF, 0X7A, 0X00); // Escribe el texto de las instrucciones - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, Lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR); + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, FIRST_LINE, Lang::getText("[INSTRUCTIONS] 01"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR); - const int anchor1 = first_line + space_post_header; - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 0, Lang::getText("[INSTRUCTIONS] 02"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_between_lines * 1, Lang::getText("[INSTRUCTIONS] 03"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 2, Lang::getText("[INSTRUCTIONS] 04"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor1 + space_new_paragraph + space_between_lines * 3, Lang::getText("[INSTRUCTIONS] 05"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); + const int ANCHOR1 = FIRST_LINE + SPACE_POST_HEADER; + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 0, Lang::getText("[INSTRUCTIONS] 02"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_BETWEEN_LINES * 1, Lang::getText("[INSTRUCTIONS] 03"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 2, Lang::getText("[INSTRUCTIONS] 04"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR1 + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3, Lang::getText("[INSTRUCTIONS] 05"), 1, NO_TEXT_COLOR, 1, SHADOW_TEXT_COLOR); // Escribe el texto de los objetos y sus puntos - const int anchor2 = anchor1 + space_pre_header + space_new_paragraph + space_between_lines * 3; - text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, anchor2, Lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR); + const int ANCHOR2 = ANCHOR1 + SPACE_PRE_HEADER + SPACE_NEW_PARAGRAPH + SPACE_BETWEEN_LINES * 3; + text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR2, Lang::getText("[INSTRUCTIONS] 06"), 1, ORANGE_COLOR, 1, SHADOW_TEXT_COLOR); - const int anchor3 = anchor2 + space_post_header; - text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR); - text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR); - text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR); - text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR); - text_->writeShadowed(ANCHOR_ITEM + desp_x, anchor3 + space_between_item_lines * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR); + const int ANCHOR3 = ANCHOR2 + SPACE_POST_HEADER; + text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR); + text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR); + text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR); + text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR); + text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR); // Deja el renderizador como estaba SDL_SetRenderTarget(renderer_, temp); // Da valor a la variable sprite_pos_.x = ANCHOR_ITEM; - sprite_pos_.y = anchor3 - ((param.game.item_size - text_->getCharacterSize()) / 2); + sprite_pos_.y = ANCHOR3 - ((param.game.item_size - text_->getCharacterSize()) / 2); } // Rellena el backbuffer @@ -289,14 +289,14 @@ std::vector Instructions::initializeLines(int height) { } // Método para mover las líneas con suavizado -bool Instructions::moveLines(std::vector &lines, int width, float duration, Uint32 startDelay) { +bool Instructions::moveLines(std::vector &lines, int width, float duration, Uint32 start_delay) { Uint32 current_time = SDL_GetTicks(); 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 * startDelay; + line.startTime = current_time + line.y * start_delay; } float elapsed_time = (current_time - line.startTime) / 1000.0f; // Convertir a segundos @@ -319,10 +319,10 @@ bool Instructions::moveLines(std::vector &lines, int width, float duration // Método para renderizar las líneas void Instructions::renderLines(SDL_Renderer *renderer, SDL_Texture *texture, const std::vector &lines) { - for (const auto &LINE : lines) { - SDL_FRect srcRect = {0, static_cast(LINE.y), 320, 1}; - SDL_FRect dstRect = {static_cast(LINE.x), static_cast(LINE.y), 320, 1}; - SDL_RenderTexture(renderer, texture, &srcRect, &dstRect); + for (const auto &line : lines) { + SDL_FRect src_rect = {0, static_cast(line.y), 320, 1}; + SDL_FRect dst_rect = {static_cast(line.x), static_cast(line.y), 320, 1}; + SDL_RenderTexture(renderer, texture, &src_rect, &dst_rect); } } diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index 0ff7bf1..d8bbdf2 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -52,64 +52,64 @@ void Intro::checkEvents() { while (SDL_PollEvent(&event)) { #ifdef DEBUG if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) { - static Color color = param.intro.bg_color; + static Color color_ = param.intro.bg_color; switch (event.key.key) { case SDLK_A: - if (color.r < 255) - ++color.r; + if (color_.r < 255) + ++color_.r; break; case SDLK_Z: - if (color.r > 0) - --color.r; + if (color_.r > 0) + --color_.r; break; case SDLK_S: - if (color.g < 255) - ++color.g; + if (color_.g < 255) + ++color_.g; break; case SDLK_X: - if (color.g > 0) - --color.g; + if (color_.g > 0) + --color_.g; break; case SDLK_D: - if (color.b < 255) - ++color.b; + if (color_.b < 255) + ++color_.b; break; case SDLK_C: - if (color.b > 0) - --color.b; + if (color_.b > 0) + --color_.b; break; case SDLK_F: - if (color.r < 255) - ++color.r; - if (color.g < 255) - ++color.g; - if (color.b < 255) - ++color.b; + if (color_.r < 255) + ++color_.r; + if (color_.g < 255) + ++color_.g; + if (color_.b < 255) + ++color_.b; break; case SDLK_V: - if (color.r > 0) - --color.r; - if (color.g > 0) - --color.g; - if (color.b > 0) - --color.b; + if (color_.r > 0) + --color_.r; + if (color_.g > 0) + --color_.g; + if (color_.b > 0) + --color_.b; break; default: break; } - tiled_bg_->setColor(color); + tiled_bg_->setColor(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') << (int)color_.r + << std::setw(2) << std::setfill('0') << (int)color_.g + << std::setw(2) << std::setfill('0') << (int)color_.b << std::endl; } #endif @@ -572,7 +572,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); + SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_); } \ No newline at end of file diff --git a/source/sections/logo.cpp b/source/sections/logo.cpp index 5793776..c74d89d 100644 --- a/source/sections/logo.cpp +++ b/source/sections/logo.cpp @@ -110,18 +110,18 @@ void Logo::updateJAILGAMES() { // Gestiona el color de las texturas void Logo::updateTextureColors() { - constexpr int inc = 4; + constexpr int INC = 4; // Manejo de 'sinceTexture' for (int i = 0; i <= 7; ++i) { - if (counter_ == SHOW_SINCE_SPRITE_COUNTER_MARK + inc * i) { + if (counter_ == SHOW_SINCE_SPRITE_COUNTER_MARK + INC * i) { since_texture_->setColor(color_[i].r, color_[i].g, color_[i].b); } } // Manejo de 'jailTexture' y 'sinceTexture' en el fade for (int i = 0; i <= 6; ++i) { - if (counter_ == INIT_FADE_COUNTER_MARK + inc * i) { + if (counter_ == INIT_FADE_COUNTER_MARK + INC * i) { jail_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b); since_texture_->setColor(color_[6 - i].r, color_[6 - i].g, color_[6 - i].b); } diff --git a/source/sections/title.cpp b/source/sections/title.cpp index c83751d..d8188e0 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -109,65 +109,65 @@ void Title::checkEvents() { while (SDL_PollEvent(&event)) { #ifdef DEBUG if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) { - static Color color = param.title.bg_color; + static Color color_ = param.title.bg_color; switch (event.key.key) { case SDLK_A: - if (color.r < 255) - ++color.r; + if (color_.r < 255) + ++color_.r; break; case SDLK_Z: - if (color.r > 0) - --color.r; + if (color_.r > 0) + --color_.r; break; case SDLK_S: - if (color.g < 255) - ++color.g; + if (color_.g < 255) + ++color_.g; break; case SDLK_X: - if (color.g > 0) - --color.g; + if (color_.g > 0) + --color_.g; break; case SDLK_D: - if (color.b < 255) - ++color.b; + if (color_.b < 255) + ++color_.b; break; case SDLK_C: - if (color.b > 0) - --color.b; + if (color_.b > 0) + --color_.b; break; case SDLK_F: - if (color.r < 255) - ++color.r; - if (color.g < 255) - ++color.g; - if (color.b < 255) - ++color.b; + if (color_.r < 255) + ++color_.r; + if (color_.g < 255) + ++color_.g; + if (color_.b < 255) + ++color_.b; break; case SDLK_V: - if (color.r > 0) - --color.r; - if (color.g > 0) - --color.g; - if (color.b > 0) - --color.b; + if (color_.r > 0) + --color_.r; + if (color_.g > 0) + --color_.g; + if (color_.b > 0) + --color_.b; break; default: break; } counter_ = 0; - tiled_bg_->setColor(color); + tiled_bg_->setColor(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') << (int)color_.r + << std::setw(2) << std::setfill('0') << (int)color_.g + << std::setw(2) << std::setfill('0') << (int)color_.b << std::endl; } #endif @@ -218,11 +218,11 @@ void Title::checkInput() { if (!ServiceMenu::get()->isEnabled()) { // Comprueba todos los métodos de control - for (const auto &CONTROLLER : Options::controllers) { + for (const auto &controller : Options::controllers) { // Boton START - if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) { + if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index)) { if ((state_ != TitleState::LOGO_ANIMATING || ALLOW_TITLE_ANIMATION_SKIP)) { - if (CONTROLLER.player_id == 1) { + if (controller.player_id == 1) { if (!player1_start_pressed_) { player1_start_pressed_ = true; getPlayer(1)->setPlayingState(PlayerState::TITLE_ANIMATION); @@ -231,7 +231,7 @@ void Title::checkInput() { } } - if (CONTROLLER.player_id == 2) { + if (controller.player_id == 2) { if (!player2_start_pressed_) { player2_start_pressed_ = true; getPlayer(2)->setPlayingState(PlayerState::TITLE_ANIMATION); @@ -292,9 +292,9 @@ void Title::showControllers() { // Genera el texto correspondiente for (size_t i = 0; i < NUM_CONTROLLERS; ++i) { - const size_t index = player_controller_index.at(i); - if (Options::controllers.at(index).plugged) { - text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(index).name; + const size_t INDEX = player_controller_index.at(i); + if (Options::controllers.at(INDEX).plugged) { + text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(INDEX).name; } } diff --git a/source/text.cpp b/source/text.cpp index 08efa8d..eae72a0 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -159,7 +159,7 @@ std::shared_ptr Text::writeToTexture(const std::string &text, int zoom, } // Escribe el texto con extras en una textura -std::shared_ptr Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght) { +std::shared_ptr Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) { auto renderer = Screen::get()->getRenderer(); auto texture = std::make_shared(renderer); auto width = Text::lenght(text, kerning) + shadow_distance; @@ -170,7 +170,7 @@ std::shared_ptr Text::writeDXToTexture(Uint8 flags, const std::string & texture->setAsRenderTarget(renderer); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); SDL_RenderClear(renderer); - writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght); + writeDX(flags, 0, 0, text, kerning, text_color, shadow_distance, shadow_color, lenght); SDL_SetRenderTarget(renderer, temp); return texture; @@ -198,21 +198,21 @@ void Text::writeCentered(int x, int y, const std::string &text, int kerning, int } // Escribe texto con extras -void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght) { - const auto centered = ((flags & TEXT_CENTER) == TEXT_CENTER); - const auto shadowed = ((flags & TEXT_SHADOW) == TEXT_SHADOW); - const auto colored = ((flags & TEXT_COLOR) == TEXT_COLOR); - const auto stroked = ((flags & TEXT_STROKE) == TEXT_STROKE); +void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) { + const auto CENTERED = ((flags & TEXT_CENTER) == TEXT_CENTER); + const auto SHADOWED = ((flags & TEXT_SHADOW) == TEXT_SHADOW); + const auto COLORED = ((flags & TEXT_COLOR) == TEXT_COLOR); + const auto STROKED = ((flags & TEXT_STROKE) == TEXT_STROKE); - if (centered) { + if (CENTERED) { x -= (Text::lenght(text, kerning) / 2); } - if (shadowed) { + if (SHADOWED) { writeColored(x + shadow_distance, y + shadow_distance, text, shadow_color, kerning, lenght); } - if (stroked) { + if (STROKED) { for (int dist = 1; dist <= shadow_distance; ++dist) { for (int dy = -dist; dy <= dist; ++dy) { for (int dx = -dist; dx <= dist; ++dx) { @@ -222,8 +222,8 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerni } } - if (colored) { - writeColored(x, y, text, textColor, kerning, lenght); + if (COLORED) { + writeColored(x, y, text, text_color, kerning, lenght); } else { write(x, y, text, kerning, lenght); } diff --git a/source/texture.cpp b/source/texture.cpp index 22e375f..a52f9f3 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -22,15 +22,15 @@ Texture::Texture(SDL_Renderer *renderer, const std::string &path) // Carga el fichero en la textura if (!path_.empty()) { // Obtiene la extensión - const std::string extension = path_.substr(path_.find_last_of(".") + 1); + const std::string EXTENSION = path_.substr(path_.find_last_of(".") + 1); // .png - if (extension == "png") { + if (EXTENSION == "png") { loadFromFile(path_); } // .gif - else if (extension == "gif") { + else if (EXTENSION == "gif") { // Crea la surface desde un fichero surface_ = loadSurface(path_); @@ -149,28 +149,28 @@ void Texture::setAlpha(Uint8 alpha) { } // Renderiza la textura en un punto específico -void Texture::render(int x, int y, SDL_FRect *clip, float zoomW, float zoomH, double angle, SDL_FPoint *center, SDL_FlipMode flip) { +void Texture::render(int x, int y, SDL_FRect *clip, float zoom_w, float zoom_h, double angle, SDL_FPoint *center, SDL_FlipMode flip) { // Establece el destino de renderizado en la pantalla - SDL_FRect renderQuad = {static_cast(x), static_cast(y), static_cast(width_), static_cast(height_)}; + SDL_FRect render_quad = {static_cast(x), static_cast(y), static_cast(width_), static_cast(height_)}; // Obtiene las dimesiones del clip de renderizado if (clip != nullptr) { - renderQuad.w = clip->w; - renderQuad.h = clip->h; + render_quad.w = clip->w; + render_quad.h = clip->h; } // Calcula el zoom y las coordenadas - if (zoomH != 1.0f || zoomW != 1.0f) { - renderQuad.x = renderQuad.x + (renderQuad.w / 2); - renderQuad.y = renderQuad.y + (renderQuad.h / 2); - renderQuad.w = renderQuad.w * zoomW; - renderQuad.h = renderQuad.h * zoomH; - renderQuad.x = renderQuad.x - (renderQuad.w / 2); - renderQuad.y = renderQuad.y - (renderQuad.h / 2); + if (zoom_h != 1.0f || zoom_w != 1.0f) { + render_quad.x = render_quad.x + (render_quad.w / 2); + render_quad.y = render_quad.y + (render_quad.h / 2); + render_quad.w = render_quad.w * zoom_w; + render_quad.h = render_quad.h * zoom_h; + render_quad.x = render_quad.x - (render_quad.w / 2); + render_quad.y = render_quad.y - (render_quad.h / 2); } // Renderiza a pantalla - SDL_RenderTextureRotated(renderer_, texture_, clip, &renderQuad, angle, center, flip); + SDL_RenderTextureRotated(renderer_, texture_, clip, &render_quad, angle, center, flip); } // Establece la textura como objetivo de renderizado @@ -231,16 +231,16 @@ std::shared_ptr Texture::loadSurface(const std::string &file_path) { // Crear un objeto Gif y llamar a la función loadGif GIF::Gif gif; Uint16 w = 0, h = 0; - std::vector rawPixels = gif.loadGif(buffer.data(), w, h); - if (rawPixels.empty()) { + std::vector raw_pixels = gif.loadGif(buffer.data(), w, h); + if (raw_pixels.empty()) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: No se pudo cargar el GIF %s", file_path.c_str()); return nullptr; } // Si el constructor de Surface espera un std::shared_ptr: - size_t pixelCount = rawPixels.size(); - auto pixels = std::shared_ptr(new Uint8[pixelCount], std::default_delete()); - std::memcpy(pixels.get(), rawPixels.data(), pixelCount); + size_t pixel_count = raw_pixels.size(); + auto pixels = std::shared_ptr(new Uint8[pixel_count], std::default_delete()); + std::memcpy(pixels.get(), raw_pixels.data(), pixel_count); auto surface = std::make_shared(w, h, pixels); diff --git a/source/tiled_bg.cpp b/source/tiled_bg.cpp index 74e77ed..1d291e0 100644 --- a/source/tiled_bg.cpp +++ b/source/tiled_bg.cpp @@ -60,11 +60,11 @@ void TiledBG::fillTexture() { SDL_SetRenderTarget(renderer_, canvas_); // Rellena la textura con el tile - const auto i_max = pos_.w * 2 / TILE_WIDTH_; - const auto j_max = pos_.h * 2 / TILE_HEIGHT_; + const auto I_MAX = pos_.w * 2 / TILE_WIDTH_; + const auto J_MAX = pos_.h * 2 / TILE_HEIGHT_; tile->setSpriteClip(0, 0, TILE_WIDTH_, TILE_HEIGHT_); - for (int i = 0; i < i_max; ++i) { - for (int j = 0; j < j_max; ++j) { + for (int i = 0; i < I_MAX; ++i) { + for (int j = 0; j < J_MAX; ++j) { tile->setX(i * TILE_WIDTH_); tile->setY(j * TILE_HEIGHT_); tile->render(); diff --git a/source/ui/menu_renderer.cpp b/source/ui/menu_renderer.cpp index a533221..c8784b6 100644 --- a/source/ui/menu_renderer.cpp +++ b/source/ui/menu_renderer.cpp @@ -15,9 +15,9 @@ MenuRenderer::MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr void MenuRenderer::render(const ServiceMenu *menu_state) { // Dibuja la sombra if (param.service_menu.drop_shadow) { - SDL_FRect shadowRect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h}; + SDL_FRect shadow_rect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h}; SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64); - SDL_RenderFillRect(Screen::get()->getRenderer(), &shadowRect); + SDL_RenderFillRect(Screen::get()->getRenderer(), &shadow_rect); } // Dibuja el fondo @@ -43,8 +43,8 @@ void MenuRenderer::render(const ServiceMenu *menu_state) { y = options_y_; const auto &option_pairs = menu_state->getOptionPairs(); for (size_t i = 0; i < option_pairs.size(); ++i) { - const bool is_selected = (i == menu_state->getSelectedIndex()); - const Color ¤t_color = is_selected ? param.service_menu.selected_color : param.service_menu.text_color; + const bool IS_SELECTED = (i == menu_state->getSelectedIndex()); + const Color ¤t_color = IS_SELECTED ? param.service_menu.selected_color : param.service_menu.text_color; if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) { element_text_->writeColored(rect_.x + ServiceMenu::OPTIONS_HORIZONTAL_PADDING_, y, option_pairs.at(i).first, current_color, -2); @@ -177,17 +177,17 @@ int MenuRenderer::getMenuWidthForGroup(ServiceMenu::SettingsGroup group) const { } void MenuRenderer::updateColorCounter() { - static Uint64 lastUpdate = SDL_GetTicks(); - Uint64 currentTicks = SDL_GetTicks(); - if (currentTicks - lastUpdate >= 50) { + static Uint64 last_update_ = SDL_GetTicks(); + Uint64 current_ticks = SDL_GetTicks(); + if (current_ticks - last_update_ >= 50) { color_counter_++; - lastUpdate = currentTicks; + last_update_ = current_ticks; } } Color MenuRenderer::getAnimatedSelectedColor() { - static auto colorCycle = generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HUE_WAVE); - return colorCycle.at(color_counter_ % colorCycle.size()); + static auto color_cycle_ = generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HUE_WAVE); + return color_cycle_.at(color_counter_ % color_cycle_.size()); } SDL_FRect MenuRenderer::setRect(SDL_FRect rect) {