Lint: rename de locales (constants + const-ref vars)
Tanda de identifier-naming de variables y constantes locales a funciones
o archivos. Ninguno cross-file (los símbolos públicos quedan para una
pasada manual con VS Code).
- audio_adapter.cpp: path → PATH (const local en 3 funciones).
- vector_text.cpp: symbols → SYMBOLS, char_width_scaled → CHAR_WIDTH_SCALED,
char_height_scaled → CHAR_HEIGHT_SCALED, spacing_scaled → SPACING_SCALED
(const locales en render/renderCentered/get_text_width).
- physics_world.cpp: acceleration → ACCELERATION (const local en update).
- constants.hpp::dins_zona_joc: point → POINT.
- game_scene.cpp:
- stepGameOver: game_over_text → GAME_OVER_TEXT.
- dibuixar_marcador: scale/spacing → SCALE/SPACING (const), y la ref
local 'scoreboard' (const SDL_FRect&) → 'scoreboard_zone' para no
colisionar con Defaults::Zones::SCOREBOARD (las refs no son
"constant" según el .clang-tidy y deben ser lower_case).
- dibuixar_missatge_stage: max_width → MAX_WIDTH (const local).
- dibuixar_continue: continue_text/counter_str/continues_text →
UPPER_CASE.
- title_scene.cpp::draw (sección MAIN): spacing → SPACING, main_text →
MAIN_TEXT, escala_main → MAIN_SCALE.
- shape_renderer.cpp: const Vec2& SHAPE_CENTRE → shape_centre (es ref,
no constant).
- collision_system.cpp: const Vec2& POS_ENEMIC → enemy_pos (ref + traducción).
- init_hud_animator.cpp: refs ZONA → zone (en 2 funciones), SCOREBOARD →
scoreboard_zone (sin colisionar con Defaults::Zones::SCOREBOARD).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1214599c4c
commit
c80212adb9
9 files changed
+66
-66
No files matched your search
@@ -54,21 +54,21 @@ auto getMusic(const std::string& name) -> Ja::Music* {
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
const std::string path = normalizeMusicPath(name);
|
||||
auto bytes = Resource::Helper::loadFile(path);
|
||||
const std::string PATH = normalizeMusicPath(name);
|
||||
auto bytes = Resource::Helper::loadFile(PATH);
|
||||
if (bytes.empty()) {
|
||||
std::cerr << "[AudioResource] no se ha podido cargar música: " << path << "\n";
|
||||
std::cerr << "[AudioResource] no se ha podido cargar música: " << PATH << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ja::Music* raw = Ja::loadMusic(bytes.data(), static_cast<std::uint32_t>(bytes.size()), name.c_str());
|
||||
if (raw == nullptr) {
|
||||
std::cerr << "[AudioResource] decodificación de música falló: " << path << "\n";
|
||||
std::cerr << "[AudioResource] decodificación de música falló: " << PATH << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cache.emplace(name, std::unique_ptr<Ja::Music>(raw));
|
||||
std::cout << "[AudioResource] música cargada: " << path << "\n";
|
||||
std::cout << "[AudioResource] música cargada: " << PATH << "\n";
|
||||
return raw;
|
||||
}
|
||||
|
||||
@@ -78,21 +78,21 @@ auto getSound(const std::string& name) -> Ja::Sound* {
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
const std::string path = normalizeSoundPath(name);
|
||||
auto bytes = Resource::Helper::loadFile(path);
|
||||
const std::string PATH = normalizeSoundPath(name);
|
||||
auto bytes = Resource::Helper::loadFile(PATH);
|
||||
if (bytes.empty()) {
|
||||
std::cerr << "[AudioResource] no se ha podido cargar sonido: " << path << "\n";
|
||||
std::cerr << "[AudioResource] no se ha podido cargar sonido: " << PATH << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ja::Sound* raw = Ja::loadSound(bytes.data(), static_cast<std::uint32_t>(bytes.size()));
|
||||
if (raw == nullptr) {
|
||||
std::cerr << "[AudioResource] decodificación de sonido falló: " << path << "\n";
|
||||
std::cerr << "[AudioResource] decodificación de sonido falló: " << PATH << "\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cache.emplace(name, std::unique_ptr<Ja::Sound>(raw));
|
||||
std::cout << "[AudioResource] sonido cargado: " << path << "\n";
|
||||
std::cout << "[AudioResource] sonido cargado: " << PATH << "\n";
|
||||
return raw;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ void VectorText::load_charset() {
|
||||
}
|
||||
|
||||
// Cargar símbolos
|
||||
const std::string symbols[] = {".", ",", "-", ":", "!", "?"};
|
||||
for (const auto& sym : symbols) {
|
||||
const std::string SYMBOLS[] = {".", ",", "-", ":", "!", "?"};
|
||||
for (const auto& sym : SYMBOLS) {
|
||||
char c = sym[0];
|
||||
std::string filename = get_shape_filename(c);
|
||||
auto shape = ShapeLoader::load(filename);
|
||||
@@ -185,13 +185,13 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
}
|
||||
|
||||
// Ancho de un carácter base (20 px a scale 1.0)
|
||||
const float char_width_scaled = BASE_CHAR_WIDTH * scale;
|
||||
const float CHAR_WIDTH_SCALED = BASE_CHAR_WIDTH * scale;
|
||||
|
||||
// Spacing escalado
|
||||
const float spacing_scaled = spacing * scale;
|
||||
const float SPACING_SCALED = spacing * scale;
|
||||
|
||||
// Altura de un carácter escalado (necesario para ajustar Y)
|
||||
const float char_height_scaled = BASE_CHAR_HEIGHT * scale;
|
||||
const float CHAR_HEIGHT_SCALED = BASE_CHAR_HEIGHT * scale;
|
||||
|
||||
// Posición X del borde izquierdo del carácter actual
|
||||
// (se ajustará +BASE_CHAR_WIDTH/2 para obtener el centro al renderizar)
|
||||
@@ -210,7 +210,7 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
|
||||
// Manejar espacios (avanzar sin dibujar)
|
||||
if (c == ' ') {
|
||||
current_x += char_width_scaled + spacing_scaled;
|
||||
current_x += CHAR_WIDTH_SCALED + SPACING_SCALED;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -220,16 +220,16 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
// Renderizar carácter
|
||||
// Ajustar X e Y para que position represente esquina superior izquierda
|
||||
// (render_shape espera el centro, así que sumamos la mitad de ancho y altura)
|
||||
Vec2 char_pos = {.x = current_x + (char_width_scaled / 2.0F), .y = position.y + (char_height_scaled / 2.0F)};
|
||||
Vec2 char_pos = {.x = current_x + (CHAR_WIDTH_SCALED / 2.0F), .y = position.y + (CHAR_HEIGHT_SCALED / 2.0F)};
|
||||
Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, scale, 1.0F, brightness);
|
||||
|
||||
// Avanzar posición
|
||||
current_x += char_width_scaled + spacing_scaled;
|
||||
current_x += CHAR_WIDTH_SCALED + SPACING_SCALED;
|
||||
} else {
|
||||
// Carácter no soportado: saltar (o renderizar '?' en el futuro)
|
||||
std::cerr << "[VectorText] Warning: caràcter no suportat '" << c << "'"
|
||||
<< '\n';
|
||||
current_x += char_width_scaled + spacing_scaled;
|
||||
current_x += CHAR_WIDTH_SCALED + SPACING_SCALED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,8 +254,8 @@ auto VectorText::get_text_width(const std::string& text, float scale, float spac
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
const float char_width_scaled = BASE_CHAR_WIDTH * scale;
|
||||
const float spacing_scaled = spacing * scale;
|
||||
const float CHAR_WIDTH_SCALED = BASE_CHAR_WIDTH * scale;
|
||||
const float SPACING_SCALED = spacing * scale;
|
||||
|
||||
// Contar caracteres visuals (no bytes) - manejar UTF-8
|
||||
size_t visual_chars = 0;
|
||||
@@ -273,7 +273,7 @@ auto VectorText::get_text_width(const std::string& text, float scale, float spac
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
auto VectorText::get_text_height(float scale) const -> float {
|
||||
|
||||
@@ -42,8 +42,8 @@ void PhysicsWorld::integrate(float dt) {
|
||||
}
|
||||
|
||||
// Aplicar fuerzas acumuladas → aceleración
|
||||
const Vec2 acceleration = body->force_accumulator * body->inverse_mass;
|
||||
body->velocity += acceleration * dt;
|
||||
const Vec2 ACCELERATION = body->force_accumulator * body->inverse_mass;
|
||||
body->velocity += ACCELERATION * dt;
|
||||
|
||||
// Damping exponencial: equivalente a v *= exp(-damping * dt)
|
||||
// Aproximación lineal cuando damping*dt es pequeño.
|
||||
|
||||
@@ -88,20 +88,20 @@ void render_shape(Rendering::Renderer* renderer,
|
||||
return;
|
||||
}
|
||||
|
||||
const Vec2& SHAPE_CENTRE = shape->getCenter();
|
||||
const Vec2& shape_centre = shape->getCenter();
|
||||
|
||||
for (const auto& primitive : shape->get_primitives()) {
|
||||
if (primitive.type == Graphics::PrimitiveType::POLYLINE) {
|
||||
// POLYLINE: conectar puntos consecutivos.
|
||||
for (size_t i = 0; i < primitive.points.size() - 1; i++) {
|
||||
const Vec2 P1 = transformPoint(primitive.points[i], SHAPE_CENTRE, position, angle, scale, rotation_3d);
|
||||
const Vec2 P2 = transformPoint(primitive.points[i + 1], SHAPE_CENTRE, position, angle, scale, rotation_3d);
|
||||
const Vec2 P1 = transformPoint(primitive.points[i], shape_centre, position, angle, scale, rotation_3d);
|
||||
const Vec2 P2 = transformPoint(primitive.points[i + 1], shape_centre, position, angle, scale, rotation_3d);
|
||||
linea(renderer, static_cast<int>(P1.x), static_cast<int>(P1.y),
|
||||
static_cast<int>(P2.x), static_cast<int>(P2.y), brightness, 0.0F, color);
|
||||
}
|
||||
} else if (primitive.points.size() >= 2) { // LINE
|
||||
const Vec2 P1 = transformPoint(primitive.points[0], SHAPE_CENTRE, position, angle, scale, rotation_3d);
|
||||
const Vec2 P2 = transformPoint(primitive.points[1], SHAPE_CENTRE, position, angle, scale, rotation_3d);
|
||||
const Vec2 P1 = transformPoint(primitive.points[0], shape_centre, position, angle, scale, rotation_3d);
|
||||
const Vec2 P2 = transformPoint(primitive.points[1], shape_centre, position, angle, scale, rotation_3d);
|
||||
linea(renderer, static_cast<int>(P1.x), static_cast<int>(P1.y),
|
||||
static_cast<int>(P2.x), static_cast<int>(P2.y), brightness, 0.0F, color);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user