Fase 1d: rename del codi restant (effects, stage_system, locals)
Sweep final del naming a CamelCase/camelBack/lower_case:
Fitxers renombrats:
- effects/gestor_puntuacio_flotant.{hpp,cpp} -> floating_score_manager.{hpp,cpp}
- effects/puntuacio_flotant.hpp -> floating_score.hpp
Tipus (CamelCase):
- GestorPuntuacioFlotant -> FloatingScoreManager
- PuntuacioFlotant -> FloatingScore
- ConfigStage -> StageConfig
- ConfigSistemaStages -> StageSystemConfig
- NauTitol -> TitleShip
- EstatNau -> ShipState
Metodes publics (camelBack):
- obte_renderer -> getRenderer
- get_num_actius -> getActiveCount
- calcular_direccio_explosio -> computeExplosionDirection
- trobar_slot_lliure -> findFreeSlot
- explotar -> explode
- reiniciar -> reset
- es_valida -> isValid
- parsejar_fitxer -> parseFile
- carregar -> load
- crear_explosio -> createExplosion
- registrar_puntuacio -> registerScore
- construir_marcador -> buildScoreboard
- render_centered -> renderCentered
Camps struct publics (snake_case):
- actiu/actius -> active
- rotacio -> rotation, rotacio_visual -> visual_rotation
- acceleracio -> acceleration
- velocitat -> velocity
- escala/escala_inicial/objectiu/actual -> scale/initial_scale/...
- posicio/posicio_inicial/objectiu/actual -> position/initial_position/...
- fase_oscilacio -> oscillation_phase
- temps_estat -> state_time
- jugador_id -> player_id
- estat -> state
- brillantor -> brightness
- tipus -> type
Camps privats (sufix _):
- naus_ -> ships_, orni_ -> enemies_, bales_ -> bullets_
- gestor_puntuacio_ -> floating_score_manager_
- punt_mort_ -> death_position_, punt_spawn_ -> spawn_position_
- itocado_per_jugador_ -> hit_timer_per_player_
- vides_per_jugador_ -> lives_per_player_
- puntuacio_per_jugador_ -> score_per_player_
- estat_game_over_ -> game_over_state_
- continues_usados_ -> continues_used_
Constants:
- MARGE_ESQ/DRET/DALT/BAIX -> MARGIN_LEFT/RIGHT/TOP/BOTTOM
Variables locals i parametres comuns (snake_case):
- nau -> ship, enemic -> enemy, bala -> bullet
- forma -> shape, punt(s) -> point(s)
- jugador -> player, partida -> match
- temps -> time, missatge -> message
Diff: 59 fitxers, +1000/-1000 (simetric). Compila i enllaça.
Pendents per a futures fases (no bloquejants):
- Comentaris de capçalera en catala -> castella
- Variables locals/parametres minoritaris en catala
- Include guards (queden alguns #ifndef en lloc de #pragma once)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace Rendering {
|
||||
|
||||
// Factor d'escala global (inicialitzat a 1.0 per defecte)
|
||||
// Factor d'scale global (inicialitzat a 1.0 per defecte)
|
||||
float g_current_scale_factor = 1.0F;
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace Rendering {
|
||||
|
||||
// Factor d'escala global (actualitzat cada frame per SDLManager)
|
||||
// Factor d'scale global (actualitzat cada frame per SDLManager)
|
||||
extern float g_current_scale_factor;
|
||||
|
||||
// Transforma coordenada lògica a física amb arrodoniment
|
||||
@@ -19,7 +19,7 @@ inline int transform_y(int logical_y, float scale) {
|
||||
return static_cast<int>(std::round(logical_y * scale));
|
||||
}
|
||||
|
||||
// Variant que usa el factor d'escala global
|
||||
// Variant que usa el factor d'scale global
|
||||
inline int transform_x(int logical_x) {
|
||||
return transform_x(logical_x, g_current_scale_factor);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace Rendering {
|
||||
|
||||
// Dibuixa una línia entre dos punts en coordenades lògiques (640x480).
|
||||
// brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor).
|
||||
// Dibuixa una línia entre dos points en coordenades lògiques (640x480).
|
||||
// brightness: factor de brightness (0.0-1.0, default 1.0 = màxima brightness).
|
||||
void linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, float brightness = 1.0F);
|
||||
|
||||
// Estableix el color global de les línies (utilitzat per ColorOscillator).
|
||||
|
||||
@@ -283,7 +283,7 @@ void SDLManager::updateViewport() {
|
||||
}
|
||||
|
||||
void SDLManager::updateRenderingContext() const {
|
||||
// Actualitzar el factor d'escala global per a totes les funcions de renderitzat
|
||||
// Actualitzar el factor d'scale global per a totes les funcions de renderitzat
|
||||
Rendering::g_current_scale_factor = zoom_factor_;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ void SDLManager::updateColors(float delta_time) {
|
||||
|
||||
// [NUEVO] Actualitzar comptador de FPS
|
||||
void SDLManager::updateFPS(float delta_time) {
|
||||
// Acumular temps i frames
|
||||
// Acumular time i frames
|
||||
fps_accumulator_ += delta_time;
|
||||
fps_frame_count_++;
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ class SDLManager {
|
||||
void updateFPS(float delta_time);
|
||||
|
||||
// Getters
|
||||
SDL_Renderer* obte_renderer() { return renderer_; }
|
||||
SDL_Renderer* getRenderer() { return renderer_; }
|
||||
[[nodiscard]] float getScaleFactor() const { return zoom_factor_; }
|
||||
|
||||
// [NUEVO] Actualitzar títol de la finestra
|
||||
void setWindowTitle(const std::string& title);
|
||||
|
||||
// [NUEVO] Actualitzar context de renderitzat (factor d'escala global)
|
||||
// [NUEVO] Actualitzar context de renderitzat (factor d'scale global)
|
||||
void updateRenderingContext() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
namespace Rendering {
|
||||
|
||||
// Helper: aplicar rotació 3D a un punt 2D (assumeix Z=0)
|
||||
// Helper: aplicar rotació 3D a un point 2D (assumeix Z=0)
|
||||
static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
float z = 0.0F; // Tots els punts 2D comencen a Z=0
|
||||
float z = 0.0F; // Tots els points 2D comencen a Z=0
|
||||
|
||||
// Pitch (rotació eix X): cabeceo arriba/baix
|
||||
float cos_pitch = std::cos(rot.pitch);
|
||||
@@ -33,7 +33,7 @@ static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
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 → +∞)
|
||||
// Naus volen cap al point de fuga (320, 240) a "infinit" (Z → +∞)
|
||||
// Z més gran = més lluny = més petit a pantalla
|
||||
constexpr float perspective_factor = 500.0F;
|
||||
float scale_factor = perspective_factor / (perspective_factor + z2);
|
||||
@@ -41,9 +41,9 @@ static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
return {.x = x3 * scale_factor, .y = y3 * scale_factor};
|
||||
}
|
||||
|
||||
// Helper: transformar un punt amb rotació, escala i trasllació
|
||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& posicio, float angle, float escala, const Rotation3D* rotation_3d) {
|
||||
// 1. Centrar el punt respecte al centre de la forma
|
||||
// Helper: transformar un point amb rotació, scale i trasllació
|
||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale, const Rotation3D* rotation_3d) {
|
||||
// 1. Centrar el point respecte al centre de la shape
|
||||
float centered_x = point.x - shape_centre.x;
|
||||
float centered_y = point.y - shape_centre.y;
|
||||
|
||||
@@ -54,9 +54,9 @@ static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const V
|
||||
centered_y = rotated_3d.y;
|
||||
}
|
||||
|
||||
// 3. Aplicar escala al punt (després de rotació 3D)
|
||||
float scaled_x = centered_x * escala;
|
||||
float scaled_y = centered_y * escala;
|
||||
// 3. Aplicar scale al point (després de rotació 3D)
|
||||
float scaled_x = centered_x * scale;
|
||||
float scaled_y = centered_y * scale;
|
||||
|
||||
// 4. Aplicar rotació 2D (Z-axis, tradicional)
|
||||
// IMPORTANT: En el sistema original, angle=0 apunta AMUNT (no dreta)
|
||||
@@ -69,19 +69,19 @@ static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const V
|
||||
float rotated_y = (scaled_x * sin_a) + (scaled_y * cos_a);
|
||||
|
||||
// 5. Aplicar trasllació a posició mundial
|
||||
return {.x = rotated_x + posicio.x, .y = rotated_y + posicio.y};
|
||||
return {.x = rotated_x + position.x, .y = rotated_y + position.y};
|
||||
}
|
||||
|
||||
void render_shape(SDL_Renderer* renderer,
|
||||
const std::shared_ptr<Graphics::Shape>& shape,
|
||||
const Vec2& posicio,
|
||||
const Vec2& position,
|
||||
float angle,
|
||||
float escala,
|
||||
float scale,
|
||||
float progress,
|
||||
float brightness,
|
||||
const Rotation3D* rotation_3d) {
|
||||
// Verificar que la forma és vàlida
|
||||
if (!shape || !shape->es_valida()) {
|
||||
// Verificar que la shape és vàlida
|
||||
if (!shape || !shape->isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,25 +90,25 @@ void render_shape(SDL_Renderer* renderer,
|
||||
return;
|
||||
}
|
||||
|
||||
// Obtenir el centre de la forma per a transformacions
|
||||
// Obtenir el centre de la shape per a transformacions
|
||||
const Vec2& shape_centre = shape->getCenter();
|
||||
|
||||
// Iterar sobre totes les primitives
|
||||
for (const auto& primitive : shape->get_primitives()) {
|
||||
if (primitive.type == Graphics::PrimitiveType::POLYLINE) {
|
||||
// POLYLINE: connectar punts consecutius
|
||||
// POLYLINE: connectar points consecutius
|
||||
for (size_t i = 0; i < primitive.points.size() - 1; i++) {
|
||||
Vec2 p1 = transform_point(primitive.points[i], shape_centre, posicio, angle, escala, rotation_3d);
|
||||
Vec2 p2 = transform_point(primitive.points[i + 1], shape_centre, posicio, angle, escala, rotation_3d);
|
||||
Vec2 p1 = transform_point(primitive.points[i], shape_centre, position, angle, scale, rotation_3d);
|
||||
Vec2 p2 = transform_point(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);
|
||||
}
|
||||
} else { // PrimitiveType::LINE
|
||||
// LINE: exactament 2 punts
|
||||
// LINE: exactament 2 points
|
||||
if (primitive.points.size() >= 2) {
|
||||
Vec2 p1 = transform_point(primitive.points[0], shape_centre, posicio, angle, escala, rotation_3d);
|
||||
Vec2 p2 = transform_point(primitive.points[1], shape_centre, posicio, angle, escala, rotation_3d);
|
||||
Vec2 p1 = transform_point(primitive.points[0], shape_centre, position, angle, scale, rotation_3d);
|
||||
Vec2 p2 = transform_point(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);
|
||||
|
||||
@@ -32,19 +32,19 @@ struct Rotation3D {
|
||||
}
|
||||
};
|
||||
|
||||
// Renderitzar forma amb transformacions
|
||||
// Renderitzar shape amb transformacions
|
||||
// - renderer: SDL renderer
|
||||
// - shape: forma vectorial a draw
|
||||
// - posicio: posició del centre en coordenades mundials
|
||||
// - shape: shape vectorial a draw
|
||||
// - position: posició del centre en coordenades mundials
|
||||
// - angle: rotació en radians (0 = amunt, sentit horari)
|
||||
// - escala: factor d'escala (1.0 = mida original)
|
||||
// - scale: factor d'scale (1.0 = mida original)
|
||||
// - progress: progrés de l'animació (0.0-1.0, default 1.0 = tot visible)
|
||||
// - brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor)
|
||||
// - brightness: factor de brightness (0.0-1.0, default 1.0 = màxima brightness)
|
||||
void render_shape(SDL_Renderer* renderer,
|
||||
const std::shared_ptr<Graphics::Shape>& shape,
|
||||
const Vec2& posicio,
|
||||
const Vec2& position,
|
||||
float angle,
|
||||
float escala = 1.0F,
|
||||
float scale = 1.0F,
|
||||
float progress = 1.0F,
|
||||
float brightness = 1.0F,
|
||||
const Rotation3D* rotation_3d = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user