jugant amb clang-tidy

This commit is contained in:
2025-07-19 22:38:01 +02:00
parent 1d3fd79a9e
commit a7ef29b750
28 changed files with 735 additions and 734 deletions

View File

@@ -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<int>(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<int>(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<int>(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<int>(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<float>(x - (w_ / 2));
const int min_x = play_area_.x;
const int max_x = play_area_.w - w_;
x_ = std::clamp(x_, static_cast<float>(min_x), static_cast<float>(max_x));
const int MIN_X = play_area_.x;
const int MAX_X = play_area_.w - w_;
x_ = std::clamp(x_, static_cast<float>(MIN_X), static_cast<float>(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