clang-tidy readability
This commit is contained in:
@@ -28,7 +28,7 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
switch (type_) {
|
||||
case BalloonType::BALLOON: {
|
||||
vy_ = 0;
|
||||
max_vy_ = 3.0f;
|
||||
max_vy_ = 3.0F;
|
||||
|
||||
const int INDEX = static_cast<int>(size_);
|
||||
gravity_ = param.balloon.settings.at(INDEX).grav;
|
||||
@@ -44,8 +44,8 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
}
|
||||
|
||||
case BalloonType::FLOATER: {
|
||||
default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0f);
|
||||
gravity_ = 0.00f;
|
||||
default_vy_ = max_vy_ = vy_ = fabs(vx_ * 2.0F);
|
||||
gravity_ = 0.00F;
|
||||
|
||||
const int INDEX = static_cast<int>(size_);
|
||||
h_ = w_ = BALLOON_SIZE[INDEX];
|
||||
@@ -66,12 +66,12 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
power_ = score_ = menace_ = 0;
|
||||
|
||||
vy_ = 0;
|
||||
max_vy_ = 3.0f;
|
||||
max_vy_ = 3.0F;
|
||||
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);
|
||||
sprite_->setRotateAmount(vx_ > 0.0F ? 2.0 : -2.0);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void Balloon::render() {
|
||||
|
||||
// Renderiza la estrella
|
||||
if (!invulnerable_) {
|
||||
SDL_FPoint p = {24.0f, 24.0f};
|
||||
SDL_FPoint p = {24.0F, 24.0F};
|
||||
sprite_->setRotatingCenter(p);
|
||||
sprite_->render();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ void Balloon::render() {
|
||||
// Renderizado para el resto de globos
|
||||
if (isBeingCreated()) {
|
||||
// Renderizado con transparencia
|
||||
sprite_->getTexture()->setAlpha(255 - (int)((float)creation_counter_ * (255.0f / (float)creation_counter_ini_)));
|
||||
sprite_->getTexture()->setAlpha(255 - (int)((float)creation_counter_ * (255.0F / (float)creation_counter_ini_)));
|
||||
sprite_->render();
|
||||
sprite_->getTexture()->setAlpha(255);
|
||||
} else {
|
||||
@@ -150,8 +150,9 @@ void Balloon::move() {
|
||||
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_)
|
||||
if (bouncing_sound_enabled_) {
|
||||
playSound(bouncing_sound_);
|
||||
}
|
||||
x_ = std::clamp(x_, MIN_X, MAX_X);
|
||||
vx_ = -vx_;
|
||||
// Activa el efecto de rebote o invierte la rotación
|
||||
@@ -169,8 +170,9 @@ void Balloon::move() {
|
||||
if (vy_ < 0) {
|
||||
const int MIN_Y = play_area_.y;
|
||||
if (y_ < MIN_Y) {
|
||||
if (bouncing_sound_enabled_)
|
||||
if (bouncing_sound_enabled_) {
|
||||
playSound(bouncing_sound_);
|
||||
}
|
||||
y_ = MIN_Y;
|
||||
vy_ = -vy_;
|
||||
enableBounce();
|
||||
@@ -180,8 +182,9 @@ void Balloon::move() {
|
||||
// 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) {
|
||||
if (bouncing_sound_enabled_)
|
||||
if (bouncing_sound_enabled_) {
|
||||
playSound(bouncing_sound_);
|
||||
}
|
||||
y_ = MAX_Y;
|
||||
vy_ = -default_vy_;
|
||||
if (type_ != BalloonType::POWERBALL) {
|
||||
@@ -204,9 +207,9 @@ void Balloon::move() {
|
||||
travel_y_ += speed_;
|
||||
|
||||
// Si la distancia acumulada en Y es igual a la velocidad, se aplica la gravedad
|
||||
if (travel_y_ >= 1.0f) {
|
||||
if (travel_y_ >= 1.0F) {
|
||||
// Quita el excedente
|
||||
travel_y_ -= 1.0f;
|
||||
travel_y_ -= 1.0F;
|
||||
|
||||
// Aplica la gravedad al objeto sin pasarse de una velocidad máxima
|
||||
vy_ += gravity_;
|
||||
@@ -283,10 +286,11 @@ void Balloon::setAnimation() {
|
||||
}
|
||||
|
||||
// Establece el frame de animación
|
||||
if (use_reversed_colors_)
|
||||
if (use_reversed_colors_) {
|
||||
sprite_->setCurrentAnimation(creating_animation);
|
||||
else
|
||||
} else {
|
||||
sprite_->setCurrentAnimation(isBeingCreated() ? creating_animation : normal_animation);
|
||||
}
|
||||
}
|
||||
|
||||
// Detiene el globo
|
||||
@@ -367,19 +371,21 @@ void Balloon::useNormalColor() {
|
||||
}
|
||||
|
||||
// Reproduce sonido
|
||||
void Balloon::playSound(const std::string &name) {
|
||||
if (!sound_enabled_)
|
||||
void Balloon::playSound(const std::string &name) const {
|
||||
if (!sound_enabled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
static auto audio_ = Audio::get();
|
||||
static auto *audio_ = Audio::get();
|
||||
audio_->playSound(name);
|
||||
}
|
||||
|
||||
// Explota el globo
|
||||
void Balloon::pop(bool should_sound) {
|
||||
if (should_sound) {
|
||||
if (poping_sound_enabled_)
|
||||
if (poping_sound_enabled_) {
|
||||
playSound(popping_sound_);
|
||||
}
|
||||
}
|
||||
|
||||
enabled_ = false;
|
||||
|
||||
Reference in New Issue
Block a user