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:
@@ -75,10 +75,10 @@ constexpr SDL_FRect MAIN_PLAYAREA = {
|
||||
// Ocupa: dins de MAIN_PLAYAREA, amb marges laterals
|
||||
// S'utilitza per a límits del joc, col·lisions, spawn
|
||||
constexpr SDL_FRect PLAYAREA = {
|
||||
PLAYAREA_PADDING_H, // x = 32.0
|
||||
MAIN_PLAYAREA_Y, // y = 48.0 (igual que MAIN_PLAYAREA)
|
||||
Game::WIDTH - 2.0F * PLAYAREA_PADDING_H, // w = 576.0
|
||||
MAIN_PLAYAREA_H // h = 384.0 (igual que MAIN_PLAYAREA)
|
||||
PLAYAREA_PADDING_H, // x = 32.0
|
||||
MAIN_PLAYAREA_Y, // y = 48.0 (igual que MAIN_PLAYAREA)
|
||||
Game::WIDTH - (2.0F * PLAYAREA_PADDING_H), // w = 576.0
|
||||
MAIN_PLAYAREA_H // h = 384.0 (igual que MAIN_PLAYAREA)
|
||||
};
|
||||
|
||||
// Marcador inferior (marcador actual)
|
||||
@@ -444,13 +444,13 @@ inline float P1_TARGET_X() {
|
||||
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE);
|
||||
}
|
||||
inline float P1_TARGET_Y() {
|
||||
return CENTER_Y + (Game::HEIGHT / 2.0F) * TARGET_Y_RATIO;
|
||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||
}
|
||||
inline float P2_TARGET_X() {
|
||||
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE);
|
||||
}
|
||||
inline float P2_TARGET_Y() {
|
||||
return CENTER_Y + (Game::HEIGHT / 2.0F) * TARGET_Y_RATIO;
|
||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||
}
|
||||
|
||||
// Escales d'animació (relatives a SHIP_BASE_SCALE)
|
||||
|
||||
@@ -43,7 +43,7 @@ Starfield::Starfield(SDL_Renderer* renderer,
|
||||
// Calcular radi màxim (distància del centre al racó més llunyà)
|
||||
float dx = std::max(punt_fuga_.x, area_.w - punt_fuga_.x);
|
||||
float dy = std::max(punt_fuga_.y, area_.h - punt_fuga_.y);
|
||||
radi_max_ = std::sqrt(dx * dx + dy * dy);
|
||||
radi_max_ = std::sqrt((dx * dx) + (dy * dy));
|
||||
|
||||
// Inicialitzar estrelles amb posicions distribuïdes (pre-omplir pantalla)
|
||||
for (int capa_idx = 0; capa_idx < 3; capa_idx++) {
|
||||
@@ -60,8 +60,8 @@ Starfield::Starfield(SDL_Renderer* renderer,
|
||||
|
||||
// Calcular posició des de la distància
|
||||
float radi = estrella.distancia_centre * radi_max_;
|
||||
estrella.posicio.x = punt_fuga_.x + radi * std::cos(estrella.angle);
|
||||
estrella.posicio.y = punt_fuga_.y + radi * std::sin(estrella.angle);
|
||||
estrella.posicio.x = punt_fuga_.x + (radi * std::cos(estrella.angle));
|
||||
estrella.posicio.y = punt_fuga_.y + (radi * std::sin(estrella.angle));
|
||||
|
||||
estrelles_.push_back(estrella);
|
||||
}
|
||||
@@ -78,8 +78,8 @@ void Starfield::inicialitzar_estrella(Estrella& estrella) {
|
||||
|
||||
// Posició inicial: molt prop del punt de fuga
|
||||
float radi = estrella.distancia_centre * radi_max_;
|
||||
estrella.posicio.x = punt_fuga_.x + radi * std::cos(estrella.angle);
|
||||
estrella.posicio.y = punt_fuga_.y + radi * std::sin(estrella.angle);
|
||||
estrella.posicio.x = punt_fuga_.x + (radi * std::cos(estrella.angle));
|
||||
estrella.posicio.y = punt_fuga_.y + (radi * std::sin(estrella.angle));
|
||||
}
|
||||
|
||||
// Verificar si una estrella està fora de l'àrea
|
||||
@@ -97,7 +97,7 @@ float Starfield::calcular_escala(const Estrella& estrella) const {
|
||||
// Interpolació lineal basada en distància del centre
|
||||
// distancia_centre: 0.0 (centre) → 1.0 (vora)
|
||||
return capa.escala_min +
|
||||
(capa.escala_max - capa.escala_min) * estrella.distancia_centre;
|
||||
((capa.escala_max - capa.escala_min) * estrella.distancia_centre);
|
||||
}
|
||||
|
||||
// Calcular brightness dinàmica segons distància del centre
|
||||
@@ -105,8 +105,8 @@ float Starfield::calcular_brightness(const Estrella& estrella) const {
|
||||
// Interpolació lineal: estrelles properes (vora) més brillants
|
||||
// distancia_centre: 0.0 (centre, llunyanes) → 1.0 (vora, properes)
|
||||
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
||||
(Defaults::Brightness::STARFIELD_MAX - Defaults::Brightness::STARFIELD_MIN) *
|
||||
estrella.distancia_centre;
|
||||
((Defaults::Brightness::STARFIELD_MAX - Defaults::Brightness::STARFIELD_MIN) *
|
||||
estrella.distancia_centre);
|
||||
|
||||
// Aplicar multiplicador i limitar a 1.0
|
||||
return std::min(1.0F, brightness_base * multiplicador_brightness_);
|
||||
@@ -129,7 +129,7 @@ void Starfield::actualitzar(float delta_time) {
|
||||
// Actualitzar distància del centre
|
||||
float dx_centre = estrella.posicio.x - punt_fuga_.x;
|
||||
float dy_centre = estrella.posicio.y - punt_fuga_.y;
|
||||
float dist_px = std::sqrt(dx_centre * dx_centre + dy_centre * dy_centre);
|
||||
float dist_px = std::sqrt((dx_centre * dx_centre) + (dy_centre * dy_centre));
|
||||
estrella.distancia_centre = dist_px / radi_max_;
|
||||
|
||||
// Si ha sortit de l'àrea, regenerar-la
|
||||
|
||||
@@ -222,7 +222,7 @@ void VectorText::render(const std::string& text, const Punt& posicio, float esca
|
||||
// Renderizar carácter
|
||||
// Ajustar X e Y para que posicio represente esquina superior izquierda
|
||||
// (render_shape espera el centro, así que sumamos la mitad de ancho y altura)
|
||||
Punt char_pos = {current_x + char_width_scaled / 2.0F, posicio.y + char_height_scaled / 2.0F};
|
||||
Punt char_pos = {current_x + (char_width_scaled / 2.0F), posicio.y + (char_height_scaled / 2.0F)};
|
||||
Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, escala, true, 1.0F, brightness);
|
||||
|
||||
// Avanzar posición
|
||||
@@ -275,7 +275,7 @@ float VectorText::get_text_width(const std::string& text, float escala, float sp
|
||||
}
|
||||
|
||||
// Ancho total = todos los caracteres VISUALES + spacing entre ellos
|
||||
return visual_chars * char_width_scaled + (visual_chars - 1) * spacing_scaled;
|
||||
return (visual_chars * char_width_scaled) + ((visual_chars - 1) * spacing_scaled);
|
||||
}
|
||||
|
||||
float VectorText::get_text_height(float escala) const {
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Easing {
|
||||
// t = progreso normalizado [0.0 - 1.0]
|
||||
// retorna valor interpolado [0.0 - 1.0]
|
||||
inline float ease_out_quad(float t) {
|
||||
return 1.0F - (1.0F - t) * (1.0F - t);
|
||||
return 1.0F - ((1.0F - t) * (1.0F - t));
|
||||
}
|
||||
|
||||
// Ease-in quadratic: empieza lento, acelera
|
||||
@@ -25,7 +25,7 @@ inline float ease_in_quad(float t) {
|
||||
inline float ease_in_out_quad(float t) {
|
||||
return (t < 0.5F)
|
||||
? 2.0F * t * t
|
||||
: 1.0F - (-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F;
|
||||
: 1.0F - ((-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F);
|
||||
}
|
||||
|
||||
// Ease-out cubic: desaceleración más suave que quadratic
|
||||
@@ -33,12 +33,12 @@ inline float ease_in_out_quad(float t) {
|
||||
// retorna valor interpolado [0.0 - 1.0]
|
||||
inline float ease_out_cubic(float t) {
|
||||
float t1 = 1.0F - t;
|
||||
return 1.0F - t1 * t1 * t1;
|
||||
return 1.0F - (t1 * t1 * t1);
|
||||
}
|
||||
|
||||
// Interpolación lineal básica (para referencia)
|
||||
inline float lerp(float start, float end, float t) {
|
||||
return start + (end - start) * t;
|
||||
return start + ((end - start) * t);
|
||||
}
|
||||
|
||||
} // namespace Easing
|
||||
|
||||
@@ -59,9 +59,9 @@ float ColorOscillator::calculateOscillationFactor(float time, float frequency) {
|
||||
}
|
||||
|
||||
SDL_Color ColorOscillator::interpolateColor(SDL_Color min, SDL_Color max, float factor) {
|
||||
return {static_cast<uint8_t>(min.r + (max.r - min.r) * factor),
|
||||
static_cast<uint8_t>(min.g + (max.g - min.g) * factor),
|
||||
static_cast<uint8_t>(min.b + (max.b - min.b) * factor),
|
||||
return {static_cast<uint8_t>(min.r + ((max.r - min.r) * factor)),
|
||||
static_cast<uint8_t>(min.g + ((max.g - min.g) * factor)),
|
||||
static_cast<uint8_t>(min.b + ((max.b - min.b) * factor)),
|
||||
255};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
float modul(const Punt& p) {
|
||||
// Càlcul de la magnitud d'un vector: sqrt(x² + y²)
|
||||
return std::sqrt(p.x * p.x + p.y * p.y);
|
||||
return std::sqrt((p.x * p.x) + (p.y * p.y));
|
||||
}
|
||||
|
||||
void diferencia(const Punt& o, const Punt& d, Punt& p) {
|
||||
|
||||
@@ -17,20 +17,20 @@ static Punt apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
// Pitch (rotació eix X): cabeceo arriba/baix
|
||||
float cos_pitch = std::cos(rot.pitch);
|
||||
float sin_pitch = std::sin(rot.pitch);
|
||||
float y1 = y * cos_pitch - z * sin_pitch;
|
||||
float z1 = y * sin_pitch + z * cos_pitch;
|
||||
float y1 = (y * cos_pitch) - (z * sin_pitch);
|
||||
float z1 = (y * sin_pitch) + (z * cos_pitch);
|
||||
|
||||
// Yaw (rotació eix Y): guiñada esquerra/dreta
|
||||
float cos_yaw = std::cos(rot.yaw);
|
||||
float sin_yaw = std::sin(rot.yaw);
|
||||
float x2 = x * cos_yaw + z1 * sin_yaw;
|
||||
float z2 = -x * sin_yaw + z1 * cos_yaw;
|
||||
float x2 = (x * cos_yaw) + (z1 * sin_yaw);
|
||||
float z2 = (-x * sin_yaw) + (z1 * cos_yaw);
|
||||
|
||||
// Roll (rotació eix Z): alabeo lateral
|
||||
float cos_roll = std::cos(rot.roll);
|
||||
float sin_roll = std::sin(rot.roll);
|
||||
float x3 = x2 * cos_roll - y1 * sin_roll;
|
||||
float y3 = x2 * sin_roll + y1 * cos_roll;
|
||||
float x3 = (x2 * cos_roll) - (y1 * sin_roll);
|
||||
float y3 = (x2 * sin_roll) + (y1 * cos_roll);
|
||||
|
||||
// Proyecció perspectiva (Z-divide simple)
|
||||
// Naus volen cap al punt de fuga (320, 240) a "infinit" (Z → +∞)
|
||||
@@ -65,8 +65,8 @@ static Punt transform_point(const Punt& point, const Punt& shape_centre, const P
|
||||
float cos_a = std::cos(angle);
|
||||
float sin_a = std::sin(angle);
|
||||
|
||||
float rotated_x = scaled_x * cos_a - scaled_y * sin_a;
|
||||
float rotated_y = scaled_x * sin_a + scaled_y * cos_a;
|
||||
float rotated_x = (scaled_x * cos_a) - (scaled_y * sin_a);
|
||||
float rotated_y = (scaled_x * sin_a) + (scaled_y * cos_a);
|
||||
|
||||
// 5. Aplicar trasllació a posició mundial
|
||||
return {rotated_x + posicio.x, rotated_y + posicio.y};
|
||||
|
||||
Reference in New Issue
Block a user