style: aplicar readability-math-missing-parentheses

- Agregar paréntesis explícitos en operaciones matemáticas para claridad
- Ejemplos: '1.0F - a * b' → '1.0F - (a * b)'
- 291 correcciones aplicadas automáticamente con clang-tidy
- Check 2/N completado

🤖 Generated with Claude Code
This commit is contained in:
2025-12-18 13:09:35 +01:00
parent bc94eff176
commit 76786203a0
20 changed files with 123 additions and 121 deletions

View File

@@ -98,8 +98,8 @@ void Bala::mou(float delta_time) {
float velocitat_efectiva = velocitat_ * delta_time;
// Calcular desplaçament (angle-PI/2 perquè angle=0 apunta amunt)
float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F);
float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F);
float dy = velocitat_efectiva * std::sin(angle_ - (Constants::PI / 2.0F));
float dx = velocitat_efectiva * std::cos(angle_ - (Constants::PI / 2.0F));
// Acumulació directa amb precisió subpíxel
centre_.y += dy;

View File

@@ -115,7 +115,7 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) {
// Rotació visual aleatòria (rad/s) dins del rang del tipus
float drotacio_range = drotacio_max - drotacio_min;
drotacio_ = drotacio_min + (static_cast<float>(std::rand()) / RAND_MAX) * drotacio_range;
drotacio_ = drotacio_min + ((static_cast<float>(std::rand()) / RAND_MAX) * drotacio_range);
rotacio_ = 0.0F;
// Inicialitzar estat d'animació
@@ -149,7 +149,7 @@ void Enemic::actualitzar(float delta_time) {
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_START;
constexpr float END = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_END;
brightness_ = START + (END - START) * smooth_t;
brightness_ = START + ((END - START) * smooth_t);
}
// Moviment autònom
@@ -195,8 +195,8 @@ void Enemic::comportament_pentagon(float delta_time) {
float velocitat_efectiva = velocitat_ * delta_time;
// Calcular desplaçament (angle-PI/2 perquè angle=0 apunta amunt)
float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F);
float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F);
float dy = velocitat_efectiva * std::sin(angle_ - (Constants::PI / 2.0F));
float dx = velocitat_efectiva * std::cos(angle_ - (Constants::PI / 2.0F));
float new_y = centre_.y + dy;
float new_x = centre_.x + dx;
@@ -246,7 +246,7 @@ void Enemic::comportament_quadrat(float delta_time) {
// Calculate angle to ship
float dx = ship_position_->x - centre_.x;
float dy = ship_position_->y - centre_.y;
float target_angle = std::atan2(dy, dx) + Constants::PI / 2.0F;
float target_angle = std::atan2(dy, dx) + (Constants::PI / 2.0F);
// Interpolate toward target angle
float angle_diff = target_angle - angle_;
@@ -262,8 +262,8 @@ void Enemic::comportament_quadrat(float delta_time) {
// Move in current direction
float velocitat_efectiva = velocitat_ * delta_time;
float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F);
float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F);
float dy = velocitat_efectiva * std::sin(angle_ - (Constants::PI / 2.0F));
float dx = velocitat_efectiva * std::cos(angle_ - (Constants::PI / 2.0F));
float new_y = centre_.y + dy;
float new_x = centre_.x + dx;
@@ -297,7 +297,7 @@ void Enemic::comportament_molinillo(float delta_time) {
if (ship_position_) {
float dx = ship_position_->x - centre_.x;
float dy = ship_position_->y - centre_.y;
float distance = std::sqrt(dx * dx + dy * dy);
float distance = std::sqrt((dx * dx) + (dy * dy));
if (distance < Defaults::Enemies::Molinillo::PROXIMITY_DISTANCE) {
// Temporarily boost rotation speed when near ship
@@ -311,8 +311,8 @@ void Enemic::comportament_molinillo(float delta_time) {
// Fast straight-line movement
float velocitat_efectiva = velocitat_ * delta_time;
float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F);
float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F);
float dy = velocitat_efectiva * std::sin(angle_ - (Constants::PI / 2.0F));
float dx = velocitat_efectiva * std::cos(angle_ - (Constants::PI / 2.0F));
float new_y = centre_.y + dy;
float new_x = centre_.x + dx;
@@ -378,17 +378,17 @@ void Enemic::actualitzar_palpitacio(float delta_time) {
float freq_range = Defaults::Enemies::Animation::PALPITACIO_FREQ_MAX -
Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN;
animacio_.palpitacio_frequencia = Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN +
(static_cast<float>(std::rand()) / RAND_MAX) * freq_range;
((static_cast<float>(std::rand()) / RAND_MAX) * freq_range);
float amp_range = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MAX -
Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN;
animacio_.palpitacio_amplitud = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN +
(static_cast<float>(std::rand()) / RAND_MAX) * amp_range;
((static_cast<float>(std::rand()) / RAND_MAX) * amp_range);
float dur_range = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MAX -
Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN;
animacio_.palpitacio_temps_restant = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN +
(static_cast<float>(std::rand()) / RAND_MAX) * dur_range;
((static_cast<float>(std::rand()) / RAND_MAX) * dur_range);
}
}
}
@@ -410,7 +410,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
// Interpolate between base and target
float initial = animacio_.drotacio_base;
float target = animacio_.drotacio_objetivo;
drotacio_ = initial + (target - initial) * smooth_t;
drotacio_ = initial + ((target - initial) * smooth_t);
}
} else {
// Random trigger for new acceleration
@@ -425,7 +425,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
float mult_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MAX -
Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN;
float multiplier = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN +
(static_cast<float>(std::rand()) / RAND_MAX) * mult_range;
((static_cast<float>(std::rand()) / RAND_MAX) * mult_range);
animacio_.drotacio_objetivo = animacio_.drotacio_base * multiplier;
@@ -433,7 +433,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
float dur_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MAX -
Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN;
animacio_.drotacio_duracio = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN +
(static_cast<float>(std::rand()) / RAND_MAX) * dur_range;
((static_cast<float>(std::rand()) / RAND_MAX) * dur_range);
}
}
}
@@ -453,7 +453,7 @@ float Enemic::calcular_escala_actual() const {
// LERP scale from 0.0 to 1.0
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_START;
constexpr float END = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_END;
escala = START + (END - START) * smooth_t;
escala = START + ((END - START) * smooth_t);
} else if (animacio_.palpitacio_activa) {
// [EXISTING] Palpitació només quan no invulnerable
escala += animacio_.palpitacio_amplitud * std::sin(animacio_.palpitacio_fase);
@@ -507,7 +507,7 @@ bool Enemic::intent_spawn_safe(const Punt& ship_pos, float& out_x, float& out_y)
// Check Euclidean distance to ship
float dx = out_x - ship_pos.x;
float dy = out_y - ship_pos.y;
float distancia = std::sqrt(dx * dx + dy * dy);
float distancia = std::sqrt((dx * dx) + (dy * dy));
// Return true if position is safe (>= 36px from ship)
return distancia >= Defaults::Enemies::Spawn::SAFETY_DISTANCE;

View File

@@ -53,8 +53,8 @@ class Enemic {
float get_drotacio() const { return drotacio_; }
Punt get_velocitat_vector() const {
return {
velocitat_ * std::cos(angle_ - Constants::PI / 2.0F),
velocitat_ * std::sin(angle_ - Constants::PI / 2.0F)};
velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
}
// Set ship position reference for tracking behavior

View File

@@ -174,10 +174,10 @@ void Nau::aplicar_fisica(float delta_time) {
// S'usa (angle - PI/2) perquè angle=0 apunta cap amunt, no cap a la dreta
// velocitat_ està en px/s, així que multipliquem per delta_time
float dy =
(velocitat_ * delta_time) * std::sin(angle_ - Constants::PI / 2.0F) +
((velocitat_ * delta_time) * std::sin(angle_ - (Constants::PI / 2.0F))) +
centre_.y;
float dx =
(velocitat_ * delta_time) * std::cos(angle_ - Constants::PI / 2.0F) +
((velocitat_ * delta_time) * std::cos(angle_ - (Constants::PI / 2.0F))) +
centre_.x;
// Boundary checking amb radi de la nau

View File

@@ -32,8 +32,8 @@ class Nau {
float get_brightness() const { return brightness_; }
Punt get_velocitat_vector() const {
return {
velocitat_ * std::cos(angle_ - Constants::PI / 2.0F),
velocitat_ * std::sin(angle_ - Constants::PI / 2.0F)};
velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
}
// Setters