clang-tidy

This commit is contained in:
2025-07-20 12:16:25 +02:00
parent a7ef29b750
commit bfda842d3c
43 changed files with 512 additions and 504 deletions

View File

@@ -46,7 +46,7 @@ void Player::init() {
firing_state_ = PlayerState::FIRING_NONE;
playing_state_ = PlayerState::WAITING;
power_up_ = false;
power_up_counter_ = POWERUP_COUNTER_;
power_up_counter_ = POWERUP_COUNTER;
extra_hit_ = false;
coffees_ = 0;
continue_ticks_ = 0;
@@ -91,12 +91,12 @@ void Player::setInput(InputAction input) {
void Player::setInputPlaying(InputAction input) {
switch (input) {
case InputAction::LEFT: {
vel_x_ = -BASE_SPEED_;
vel_x_ = -BASE_SPEED;
setWalkingState(PlayerState::WALKING_LEFT);
break;
}
case InputAction::RIGHT: {
vel_x_ = BASE_SPEED_;
vel_x_ = BASE_SPEED;
setWalkingState(PlayerState::WALKING_RIGHT);
break;
}
@@ -153,7 +153,7 @@ void Player::move() {
// Si el jugador abandona el area de juego por los laterales, restaura su posición
const float MIN_X = play_area_.x - 5;
const float MAX_X = play_area_.w + 5 - WIDTH_;
const float MAX_X = play_area_.w + 5 - WIDTH;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
@@ -163,7 +163,7 @@ void Player::move() {
// Si el jugador abandona el area de juego por los laterales lo hace rebotar
const int X = player_sprite_->getPosX();
const int MIN_X = play_area_.x;
const int MAX_X = play_area_.x + play_area_.w - WIDTH_;
const int MAX_X = play_area_.x + play_area_.w - WIDTH;
if ((X < MIN_X) || (X > MAX_X)) {
player_sprite_->setPosX(std::clamp(X, MIN_X, MAX_X));
player_sprite_->setVelX(-player_sprite_->getVelX());
@@ -171,10 +171,10 @@ void Player::move() {
}
// Si el jugador toca el suelo rebota y si tiene poca velocidad, se detiene y cambia de estado
if (player_sprite_->getPosY() > play_area_.h - HEIGHT_) {
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 NEXT_PLAYER_STATUS = IsEligibleForHighScore() ? PlayerState::ENTERING_NAME : PlayerState::CONTINUE;
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_;
@@ -183,7 +183,7 @@ void Player::move() {
playSound("jump.wav");
} else {
// Decrementa las velocidades de rebote
player_sprite_->setPosY(play_area_.h - HEIGHT_);
player_sprite_->setPosY(play_area_.h - HEIGHT);
player_sprite_->setVelY(player_sprite_->getVelY() * -0.5f);
player_sprite_->setVelX(player_sprite_->getVelX() * 0.75f);
player_sprite_->setAnimationSpeed(player_sprite_->getAnimationSpeed() * 2);
@@ -195,7 +195,7 @@ void Player::move() {
case PlayerState::TITLE_ANIMATION: {
// Si el jugador abandona el area de juego por los laterales lo detiene
/*const int X = player_sprite_->getPosX();
const int MIN_X = play_area_.x - WIDTH_;
const int MIN_X = play_area_.x - WIDTH;
const int MAX_X = play_area_.x + play_area_.w;
if ((X < MIN_X) || (X > MAX_X))
{
@@ -219,7 +219,7 @@ void Player::move() {
break;
}
pos_x_ += vel_x_ * 2.0f;
const float MIN_X = -WIDTH_;
const float MIN_X = -WIDTH;
const float MAX_X = play_area_.w;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
@@ -253,7 +253,7 @@ void Player::move() {
break;
}
pos_x_ += vel_x_;
const float MIN_X = -WIDTH_;
const float MIN_X = -WIDTH;
const float MAX_X = play_area_.w;
pos_x_ = std::clamp(pos_x_, MIN_X, MAX_X);
shiftSprite();
@@ -298,8 +298,8 @@ void Player::move() {
pos_x_ += vel_x_ / 2.0f;
if (vel_x_ > 0) {
// setInputPlaying(InputAction::RIGHT);
if (pos_x_ > param.game.game_area.rect.w - WIDTH_) {
pos_x_ = param.game.game_area.rect.w - WIDTH_;
if (pos_x_ > param.game.game_area.rect.w - WIDTH) {
pos_x_ = param.game.game_area.rect.w - WIDTH;
vel_x_ *= -1;
}
} else {
@@ -310,7 +310,7 @@ void Player::move() {
}
}
if (pos_x_ > param.game.game_area.center_x - WIDTH_ / 2) {
if (pos_x_ > param.game.game_area.center_x - WIDTH / 2) {
setWalkingState(PlayerState::WALKING_LEFT);
} else {
setWalkingState(PlayerState::WALKING_RIGHT);
@@ -326,7 +326,7 @@ void Player::move() {
// Pinta el jugador en pantalla
void Player::render() {
if (power_up_ && isPlaying()) {
if (power_up_counter_ > (POWERUP_COUNTER_ / 4) || power_up_counter_ % 20 > 4) {
if (power_up_counter_ > (POWERUP_COUNTER / 4) || power_up_counter_ % 20 > 4) {
power_sprite_->render();
}
}
@@ -406,7 +406,7 @@ void Player::setAnimation() {
void Player::updateCooldown() {
if (playing_state_ == PlayerState::PLAYING) {
if (cant_fire_counter_ > 0) {
cooling_state_counter_ = COOLING_DURATION_;
cooling_state_counter_ = COOLING_DURATION;
// La mitad del tiempo que no puede disparar tiene el brazo arriba (PlayerState::FIRING)
// y la otra mitad en retroceso (PlayerState::RECOILING)
@@ -434,8 +434,8 @@ void Player::updateCooldown() {
if (recoiling_state_counter_ > 0) {
--recoiling_state_counter_;
} else {
if (cooling_state_counter_ > COOLING_COMPLETE_) {
if (cooling_state_counter_ == COOLING_DURATION_) {
if (cooling_state_counter_ > COOLING_COMPLETE) {
if (cooling_state_counter_ == COOLING_DURATION) {
switch (firing_state_) {
case PlayerState::RECOILING_LEFT:
setFiringState(PlayerState::COOLING_LEFT);
@@ -454,7 +454,7 @@ void Player::updateCooldown() {
--cooling_state_counter_;
}
if (cooling_state_counter_ == COOLING_COMPLETE_) {
if (cooling_state_counter_ == COOLING_COMPLETE) {
setFiringState(PlayerState::FIRING_NONE);
cooling_state_counter_ = -1;
}
@@ -608,7 +608,7 @@ void Player::setPlayingState(PlayerState state) {
setScoreboardMode(ScoreboardMode::SCORE);
switch (id_) {
case 1:
pos_x_ = param.game.game_area.rect.x - WIDTH_;
pos_x_ = param.game.game_area.rect.x - WIDTH;
break;
case 2:
@@ -621,7 +621,7 @@ void Player::setPlayingState(PlayerState state) {
break;
}
case PlayerState::CREDITS: {
vel_x_ = (walking_state_ == PlayerState::WALKING_RIGHT) ? BASE_SPEED_ : -BASE_SPEED_;
vel_x_ = (walking_state_ == PlayerState::WALKING_RIGHT) ? BASE_SPEED : -BASE_SPEED;
break;
}
default:
@@ -644,7 +644,7 @@ void Player::decScoreMultiplier() {
// Establece el valor del estado
void Player::setInvulnerable(bool value) {
invulnerable_ = value;
invulnerable_counter_ = invulnerable_ ? INVULNERABLE_COUNTER_ : 0;
invulnerable_counter_ = invulnerable_ ? INVULNERABLE_COUNTER : 0;
}
// Monitoriza el estado
@@ -664,7 +664,7 @@ void Player::updateInvulnerable() {
// Establece el valor de la variable
void Player::setPowerUp() {
power_up_ = true;
power_up_counter_ = POWERUP_COUNTER_;
power_up_counter_ = POWERUP_COUNTER;
}
// Actualiza el valor de la variable
@@ -698,8 +698,8 @@ void Player::removeExtraHit() {
// Actualiza el circulo de colisión a la posición del jugador
void Player::shiftColliders() {
collider_.x = static_cast<int>(pos_x_ + (WIDTH_ / 2));
collider_.y = static_cast<int>(pos_y_ + (HEIGHT_ / 2));
collider_.x = static_cast<int>(pos_x_ + (WIDTH / 2));
collider_.y = static_cast<int>(pos_y_ + (HEIGHT / 2));
}
// Pone las texturas del jugador