style: aplicar readability-uppercase-literal-suffix

- Cambiar todos los literales float de minúscula a mayúscula (1.0f → 1.0F)
- 657 correcciones aplicadas automáticamente con clang-tidy
- Check 1/N completado

🤖 Generated with Claude Code
This commit is contained in:
2025-12-18 13:06:48 +01:00
parent 44cd0857e0
commit bc94eff176
41 changed files with 705 additions and 594 deletions

View File

@@ -15,11 +15,11 @@
Bala::Bala(SDL_Renderer* renderer)
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
centre_({0.0F, 0.0F}),
angle_(0.0F),
velocitat_(0.0F),
esta_(false),
grace_timer_(0.0f),
grace_timer_(0.0F),
brightness_(Defaults::Brightness::BALA) {
// [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load("bullet.shp");
@@ -32,10 +32,10 @@ Bala::Bala(SDL_Renderer* renderer)
void Bala::inicialitzar() {
// Inicialment inactiva
esta_ = false;
centre_ = {0.0f, 0.0f};
angle_ = 0.0f;
velocitat_ = 0.0f;
grace_timer_ = 0.0f;
centre_ = {0.0F, 0.0F};
angle_ = 0.0F;
velocitat_ = 0.0F;
grace_timer_ = 0.0F;
}
void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) {
@@ -57,7 +57,7 @@ void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) {
// Velocitat alta (el joc Pascal original usava 7 px/frame)
// 7 px/frame × 20 FPS = 140 px/s
velocitat_ = 140.0f;
velocitat_ = 140.0F;
// Activar grace period (prevents instant self-collision)
grace_timer_ = Defaults::Game::BULLET_GRACE_PERIOD;
@@ -69,10 +69,10 @@ void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) {
void Bala::actualitzar(float delta_time) {
if (esta_) {
// Decrementar grace timer
if (grace_timer_ > 0.0f) {
if (grace_timer_ > 0.0F) {
grace_timer_ -= delta_time;
if (grace_timer_ < 0.0f) {
grace_timer_ = 0.0f;
if (grace_timer_ < 0.0F) {
grace_timer_ = 0.0F;
}
}
@@ -84,7 +84,7 @@ void Bala::dibuixar() const {
if (esta_ && forma_) {
// [NUEVO] Usar render_shape en lloc de rota_pol
// Les bales roten segons l'angle de trajectòria
Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0f, true, 1.0f, brightness_);
Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0F, true, 1.0F, brightness_);
}
}
@@ -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

@@ -15,18 +15,18 @@
Enemic::Enemic(SDL_Renderer* renderer)
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
drotacio_(0.0f),
rotacio_(0.0f),
centre_({0.0F, 0.0F}),
angle_(0.0F),
velocitat_(0.0F),
drotacio_(0.0F),
rotacio_(0.0F),
esta_(false),
brightness_(Defaults::Brightness::ENEMIC),
tipus_(TipusEnemic::PENTAGON),
tracking_timer_(0.0f),
tracking_timer_(0.0F),
ship_position_(nullptr),
tracking_strength_(0.5f), // Default tracking strength
timer_invulnerabilitat_(0.0f) { // Start vulnerable
tracking_strength_(0.5F), // Default tracking strength
timer_invulnerabilitat_(0.0F) { // Start vulnerable
// [NUEVO] Forma es carrega a inicialitzar() segons el tipus
// Constructor no carrega forma per permetre tipus diferents
}
@@ -52,7 +52,7 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) {
velocitat_ = Defaults::Enemies::Quadrat::VELOCITAT;
drotacio_min = Defaults::Enemies::Quadrat::DROTACIO_MIN;
drotacio_max = Defaults::Enemies::Quadrat::DROTACIO_MAX;
tracking_timer_ = 0.0f;
tracking_timer_ = 0.0F;
break;
case TipusEnemic::MOLINILLO:
@@ -111,18 +111,18 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) {
}
// Angle aleatori de moviment
angle_ = (std::rand() % 360) * Constants::PI / 180.0f;
angle_ = (std::rand() % 360) * Constants::PI / 180.0F;
// 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;
rotacio_ = 0.0f;
rotacio_ = 0.0F;
// Inicialitzar estat d'animació
animacio_ = AnimacioEnemic(); // Reset to defaults
animacio_.drotacio_base = drotacio_;
animacio_.drotacio_objetivo = drotacio_;
animacio_.drotacio_t = 1.0f; // Start without interpolating
animacio_.drotacio_t = 1.0F; // Start without interpolating
// [NEW] Inicialitzar invulnerabilitat
timer_invulnerabilitat_ = Defaults::Enemies::Spawn::INVULNERABILITY_DURATION; // 3.0s
@@ -135,17 +135,17 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) {
void Enemic::actualitzar(float delta_time) {
if (esta_) {
// [NEW] Update invulnerability timer and brightness
if (timer_invulnerabilitat_ > 0.0f) {
if (timer_invulnerabilitat_ > 0.0F) {
timer_invulnerabilitat_ -= delta_time;
if (timer_invulnerabilitat_ < 0.0f) {
timer_invulnerabilitat_ = 0.0f;
if (timer_invulnerabilitat_ < 0.0F) {
timer_invulnerabilitat_ = 0.0F;
}
// [NEW] Update brightness with LERP during invulnerability
float t_inv = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
float t = 1.0f - t_inv; // 0.0 → 1.0
float smooth_t = t * t * (3.0f - 2.0f * t); // smoothstep
float t = 1.0F - t_inv; // 0.0 → 1.0
float smooth_t = t * t * (3.0F - 2.0F * t); // smoothstep
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_START;
constexpr float END = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_END;
@@ -169,7 +169,7 @@ void Enemic::dibuixar() const {
float escala = calcular_escala_actual();
// brightness_ is already updated in actualitzar()
Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, true, 1.0f, brightness_);
Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, true, 1.0F, brightness_);
}
}
@@ -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;
@@ -240,20 +240,20 @@ void Enemic::comportament_quadrat(float delta_time) {
// Periodically update angle toward ship
if (tracking_timer_ >= Defaults::Enemies::Quadrat::TRACKING_INTERVAL) {
tracking_timer_ = 0.0f;
tracking_timer_ = 0.0F;
if (ship_position_) {
// 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_;
// Normalize angle difference to [-π, π]
while (angle_diff > Constants::PI) angle_diff -= 2.0f * Constants::PI;
while (angle_diff < -Constants::PI) angle_diff += 2.0f * Constants::PI;
while (angle_diff > Constants::PI) angle_diff -= 2.0F * Constants::PI;
while (angle_diff < -Constants::PI) angle_diff += 2.0F * Constants::PI;
// Apply tracking strength (uses member variable, defaults to 0.5)
angle_ += angle_diff * tracking_strength_;
@@ -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;
@@ -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;
@@ -355,13 +355,13 @@ void Enemic::actualitzar_animacio(float delta_time) {
void Enemic::actualitzar_palpitacio(float delta_time) {
if (animacio_.palpitacio_activa) {
// Advance phase (2π * frequency * dt)
animacio_.palpitacio_fase += 2.0f * Constants::PI * animacio_.palpitacio_frequencia * delta_time;
animacio_.palpitacio_fase += 2.0F * Constants::PI * animacio_.palpitacio_frequencia * delta_time;
// Decrement timer
animacio_.palpitacio_temps_restant -= delta_time;
// Deactivate when timer expires
if (animacio_.palpitacio_temps_restant <= 0.0f) {
if (animacio_.palpitacio_temps_restant <= 0.0F) {
animacio_.palpitacio_activa = false;
}
} else {
@@ -372,7 +372,7 @@ void Enemic::actualitzar_palpitacio(float delta_time) {
if (rand_val < trigger_prob) {
// Activate palpitation
animacio_.palpitacio_activa = true;
animacio_.palpitacio_fase = 0.0f;
animacio_.palpitacio_fase = 0.0F;
// Randomize parameters
float freq_range = Defaults::Enemies::Animation::PALPITACIO_FREQ_MAX -
@@ -394,18 +394,18 @@ void Enemic::actualitzar_palpitacio(float delta_time) {
}
void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
if (animacio_.drotacio_t < 1.0f) {
if (animacio_.drotacio_t < 1.0F) {
// Transitioning to new target
animacio_.drotacio_t += delta_time / animacio_.drotacio_duracio;
if (animacio_.drotacio_t >= 1.0f) {
animacio_.drotacio_t = 1.0f;
if (animacio_.drotacio_t >= 1.0F) {
animacio_.drotacio_t = 1.0F;
animacio_.drotacio_base = animacio_.drotacio_objetivo; // Reached target
drotacio_ = animacio_.drotacio_base;
} else {
// Smoothstep interpolation: t² * (3 - 2t)
float t = animacio_.drotacio_t;
float smooth_t = t * t * (3.0f - 2.0f * t);
float smooth_t = t * t * (3.0F - 2.0F * t);
// Interpolate between base and target
float initial = animacio_.drotacio_base;
@@ -419,7 +419,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
if (rand_val < trigger_prob) {
// Start new transition
animacio_.drotacio_t = 0.0f;
animacio_.drotacio_t = 0.0F;
// Randomize target speed (multiplier * base)
float mult_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MAX -
@@ -439,16 +439,16 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
}
float Enemic::calcular_escala_actual() const {
float escala = 1.0f;
float escala = 1.0F;
// [NEW] Invulnerability LERP prioritza sobre palpitació
if (timer_invulnerabilitat_ > 0.0f) {
if (timer_invulnerabilitat_ > 0.0F) {
// Calculate t: 0.0 at spawn → 1.0 at end
float t_inv = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
float t = 1.0f - t_inv; // 0.0 → 1.0
float t = 1.0F - t_inv; // 0.0 → 1.0
// Apply smoothstep: t² * (3 - 2t)
float smooth_t = t * t * (3.0f - 2.0f * t);
float smooth_t = t * t * (3.0F - 2.0F * t);
// LERP scale from 0.0 to 1.0
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_START;
@@ -473,12 +473,12 @@ float Enemic::get_base_velocity() const {
case TipusEnemic::MOLINILLO:
return Defaults::Enemies::Molinillo::VELOCITAT;
}
return 0.0f;
return 0.0F;
}
float Enemic::get_base_rotation() const {
// Return the base rotation speed (drotacio_base if available, otherwise current drotacio_)
return animacio_.drotacio_base != 0.0f ? animacio_.drotacio_base : drotacio_;
return animacio_.drotacio_base != 0.0F ? animacio_.drotacio_base : drotacio_;
}
void Enemic::set_tracking_strength(float strength) {

View File

@@ -22,16 +22,16 @@ enum class TipusEnemic : uint8_t {
struct AnimacioEnemic {
// Palpitation (breathing effect)
bool palpitacio_activa = false;
float palpitacio_fase = 0.0f; // Phase in cycle (0.0-2π)
float palpitacio_frequencia = 2.0f; // Hz (cycles per second)
float palpitacio_amplitud = 0.15f; // Scale variation (±15%)
float palpitacio_temps_restant = 0.0f; // Time remaining (seconds)
float palpitacio_fase = 0.0F; // Phase in cycle (0.0-2π)
float palpitacio_frequencia = 2.0F; // Hz (cycles per second)
float palpitacio_amplitud = 0.15F; // Scale variation (±15%)
float palpitacio_temps_restant = 0.0F; // Time remaining (seconds)
// Rotation acceleration (long-term spin modulation)
float drotacio_base = 0.0f; // Base rotation speed (rad/s)
float drotacio_objetivo = 0.0f; // Target rotation speed (rad/s)
float drotacio_t = 0.0f; // Interpolation progress (0.0-1.0)
float drotacio_duracio = 0.0f; // Duration of transition (seconds)
float drotacio_base = 0.0F; // Base rotation speed (rad/s)
float drotacio_objetivo = 0.0F; // Target rotation speed (rad/s)
float drotacio_t = 0.0F; // Interpolation progress (0.0-1.0)
float drotacio_duracio = 0.0F; // Duration of transition (seconds)
};
class Enemic {
@@ -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
@@ -74,7 +74,7 @@ class Enemic {
void set_tracking_strength(float strength);
// [NEW] Invulnerability queries
bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0f; }
bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0F; }
float get_temps_invulnerabilitat() const { return timer_invulnerabilitat_; }
private:

View File

@@ -17,12 +17,12 @@
Nau::Nau(SDL_Renderer* renderer, const char* shape_file)
: renderer_(renderer),
centre_({0.0f, 0.0f}),
angle_(0.0f),
velocitat_(0.0f),
centre_({0.0F, 0.0F}),
angle_(0.0F),
velocitat_(0.0F),
esta_tocada_(false),
brightness_(Defaults::Brightness::NAU),
invulnerable_timer_(0.0f) {
invulnerable_timer_(0.0F) {
// [NUEVO] Carregar forma compartida des de fitxer
forma_ = Graphics::ShapeLoader::load(shape_file);
@@ -52,14 +52,14 @@ void Nau::inicialitzar(const Punt* spawn_point, bool activar_invulnerabilitat) {
}
// Estat inicial
angle_ = 0.0f;
velocitat_ = 0.0f;
angle_ = 0.0F;
velocitat_ = 0.0F;
// Activar invulnerabilidad solo si es respawn
if (activar_invulnerabilitat) {
invulnerable_timer_ = Defaults::Ship::INVULNERABILITY_DURATION;
} else {
invulnerable_timer_ = 0.0f;
invulnerable_timer_ = 0.0F;
}
esta_tocada_ = false;
@@ -120,10 +120,10 @@ void Nau::actualitzar(float delta_time) {
return;
// Decrementar timer de invulnerabilidad
if (invulnerable_timer_ > 0.0f) {
if (invulnerable_timer_ > 0.0F) {
invulnerable_timer_ -= delta_time;
if (invulnerable_timer_ < 0.0f) {
invulnerable_timer_ = 0.0f;
if (invulnerable_timer_ < 0.0F) {
invulnerable_timer_ = 0.0F;
}
}
@@ -160,10 +160,10 @@ void Nau::dibuixar() const {
// [NUEVO] Convertir suma de velocitat_visual a escala multiplicativa
// Radio base del ship = 12 px
// velocitat_visual = 0-6 → r = 12-18 → escala = 1.0-1.5
float velocitat_visual = velocitat_ / 33.33f;
float escala = 1.0f + (velocitat_visual / 12.0f);
float velocitat_visual = velocitat_ / 33.33F;
float escala = 1.0F + (velocitat_visual / 12.0F);
Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0f, brightness_);
Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0F, brightness_);
}
void Nau::aplicar_fisica(float delta_time) {
@@ -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
@@ -199,10 +199,10 @@ void Nau::aplicar_fisica(float delta_time) {
}
// Fricció - desacceleració gradual (time-based)
if (velocitat_ > 0.1f) {
if (velocitat_ > 0.1F) {
velocitat_ -= Defaults::Physics::FRICTION * delta_time;
if (velocitat_ < 0.0f) {
velocitat_ = 0.0f;
if (velocitat_ < 0.0F) {
velocitat_ = 0.0F;
}
}
}

View File

@@ -27,13 +27,13 @@ class Nau {
float get_angle() const { return angle_; }
bool esta_viva() const { return !esta_tocada_; }
bool esta_tocada() const { return esta_tocada_; }
bool es_invulnerable() const { return invulnerable_timer_ > 0.0f; }
bool es_invulnerable() const { return invulnerable_timer_ > 0.0F; }
const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
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