style: aplicar checks modernize-* (215 fixes)
Cambios aplicados:
- [[nodiscard]] añadido a funciones que retornan valores
- .starts_with() en lugar de .find() == 0
- Inicializadores designados {.x=0, .y=0}
- auto en castings obvios
- = default para constructores triviales
- Funciones deleted movidas a public
- std::numbers::pi_v<float> (C++20)
Checks excluidos:
- use-trailing-return-type: Estilo controversial
- avoid-c-arrays: Arrays C aceptables en ciertos contextos
This commit is contained in:
@@ -555,7 +555,7 @@ void EscenaJoc::dibuixar() {
|
||||
float centre_x = play_area.x + (play_area.w / 2.0F);
|
||||
float centre_y = play_area.y + (play_area.h / 2.0F);
|
||||
|
||||
text_.render_centered(game_over_text, {centre_x, centre_y}, escala, spacing);
|
||||
text_.render_centered(game_over_text, {.x = centre_x, .y = centre_y}, escala, spacing);
|
||||
|
||||
dibuixar_marcador();
|
||||
return;
|
||||
@@ -710,7 +710,7 @@ void EscenaJoc::tocado(uint8_t player_id) {
|
||||
float ship_angle = naus_[player_id].get_angle();
|
||||
Punt vel_nau = naus_[player_id].get_velocitat_vector();
|
||||
// Reduir a 80% la velocitat heretada per la nau (més realista)
|
||||
Punt vel_nau_80 = {vel_nau.x * 0.8F, vel_nau.y * 0.8F};
|
||||
Punt vel_nau_80 = {.x = vel_nau.x * 0.8F, .y = vel_nau.y * 0.8F};
|
||||
|
||||
debris_manager_.explotar(
|
||||
naus_[player_id].get_forma(), // Ship shape (3 lines)
|
||||
@@ -763,7 +763,7 @@ void EscenaJoc::dibuixar_marcador() {
|
||||
float centre_y = scoreboard.y + (scoreboard.h / 2.0F);
|
||||
|
||||
// Renderitzar centrat
|
||||
text_.render_centered(text, {centre_x, centre_y}, escala, spacing);
|
||||
text_.render_centered(text, {.x = centre_x, .y = centre_y}, escala, spacing);
|
||||
}
|
||||
|
||||
void EscenaJoc::dibuixar_marges_animat(float progress) const {
|
||||
@@ -844,13 +844,13 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) {
|
||||
float centre_y_final = scoreboard.y + (scoreboard.h / 2.0F);
|
||||
|
||||
// Posició Y inicial (offscreen, sota de la pantalla)
|
||||
float centre_y_inicial = static_cast<float>(Defaults::Game::HEIGHT);
|
||||
auto centre_y_inicial = static_cast<float>(Defaults::Game::HEIGHT);
|
||||
|
||||
// Interpolació amb easing
|
||||
float centre_y_animada = centre_y_inicial + ((centre_y_final - centre_y_inicial) * eased_progress);
|
||||
|
||||
// Renderitzar centrat en posició animada
|
||||
text_.render_centered(text, {centre_x, centre_y_animada}, escala, spacing);
|
||||
text_.render_centered(text, {.x = centre_x, .y = centre_y_animada}, escala, spacing);
|
||||
}
|
||||
|
||||
Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress, uint8_t player_id) const {
|
||||
@@ -874,7 +874,7 @@ Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress, uint8_t player_id)
|
||||
// Y interpola amb easing
|
||||
float y_animada = y_inicial + ((y_final - y_inicial) * eased_progress);
|
||||
|
||||
return {x_final, y_animada};
|
||||
return {.x = x_final, .y = y_animada};
|
||||
}
|
||||
|
||||
float EscenaJoc::calcular_progress_rango(float global_progress, float ratio_init, float ratio_end) const {
|
||||
@@ -1061,8 +1061,8 @@ void EscenaJoc::detectar_col·lisio_naus_enemics() {
|
||||
const Punt& pos_enemic = enemic.get_centre();
|
||||
|
||||
// Calculate squared distance (avoid sqrt)
|
||||
float dx = static_cast<float>(pos_nau.x - pos_enemic.x);
|
||||
float dy = static_cast<float>(pos_nau.y - pos_enemic.y);
|
||||
auto dx = static_cast<float>(pos_nau.x - pos_enemic.x);
|
||||
auto dy = static_cast<float>(pos_nau.y - pos_enemic.y);
|
||||
float distancia_quadrada = (dx * dx) + (dy * dy);
|
||||
|
||||
// Check collision
|
||||
@@ -1220,7 +1220,7 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) {
|
||||
float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0F);
|
||||
|
||||
// Render only the partial message (typewriter effect)
|
||||
Punt pos = {x, y};
|
||||
Punt pos = {.x = x, .y = y};
|
||||
text_.render(partial_message, pos, escala, spacing);
|
||||
}
|
||||
|
||||
@@ -1243,8 +1243,8 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const {
|
||||
}
|
||||
|
||||
return {
|
||||
zona.x + (zona.w * x_ratio),
|
||||
zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
|
||||
.x = zona.x + (zona.w * x_ratio),
|
||||
.y = zona.y + (zona.h * Defaults::Game::SPAWN_Y_RATIO)};
|
||||
}
|
||||
|
||||
void EscenaJoc::disparar_bala(uint8_t player_id) {
|
||||
@@ -1266,7 +1266,7 @@ void EscenaJoc::disparar_bala(uint8_t player_id) {
|
||||
float sin_a = std::sin(ship_angle);
|
||||
float tip_x = (LOCAL_TIP_X * cos_a) - (LOCAL_TIP_Y * sin_a) + ship_centre.x;
|
||||
float tip_y = (LOCAL_TIP_X * sin_a) + (LOCAL_TIP_Y * cos_a) + ship_centre.y;
|
||||
Punt posicio_dispar = {tip_x, tip_y};
|
||||
Punt posicio_dispar = {.x = tip_x, .y = tip_y};
|
||||
|
||||
// Buscar primera bala inactiva en el pool del jugador
|
||||
int start_idx = player_id * 3; // P1=[0,1,2], P2=[3,4,5]
|
||||
@@ -1400,7 +1400,7 @@ void EscenaJoc::dibuixar_continue() {
|
||||
float centre_x = play_area.x + (play_area.w / 2.0F);
|
||||
float centre_y_continue = play_area.y + (play_area.h * y_ratio_continue);
|
||||
|
||||
text_.render_centered(continue_text, {centre_x, centre_y_continue}, escala_continue, spacing);
|
||||
text_.render_centered(continue_text, {.x = centre_x, .y = centre_y_continue}, escala_continue, spacing);
|
||||
|
||||
// Countdown number (using constants)
|
||||
const std::string counter_str = std::to_string(continue_counter_);
|
||||
@@ -1409,7 +1409,7 @@ void EscenaJoc::dibuixar_continue() {
|
||||
|
||||
float centre_y_counter = play_area.y + (play_area.h * y_ratio_counter);
|
||||
|
||||
text_.render_centered(counter_str, {centre_x, centre_y_counter}, escala_counter, spacing);
|
||||
text_.render_centered(counter_str, {.x = centre_x, .y = centre_y_counter}, escala_counter, spacing);
|
||||
|
||||
// "CONTINUES LEFT" (conditional + using constants)
|
||||
if (!Defaults::Game::INFINITE_CONTINUES) {
|
||||
@@ -1419,7 +1419,7 @@ void EscenaJoc::dibuixar_continue() {
|
||||
|
||||
float centre_y_info = play_area.y + (play_area.h * y_ratio_info);
|
||||
|
||||
text_.render_centered(continues_text, {centre_x, centre_y_info}, escala_info, spacing);
|
||||
text_.render_centered(continues_text, {.x = centre_x, .y = centre_y_info}, escala_info, spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user