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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user