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:
@@ -1,4 +1,4 @@
|
||||
// bala.cpp - Implementació de projectils de la nau
|
||||
// bullet.cpp - Implementació de projectils de la ship
|
||||
// © 1999 Visente i Sergi (versió Pascal)
|
||||
// © 2025 Port a C++20 amb SDL3
|
||||
|
||||
@@ -26,11 +26,11 @@ Bullet::Bullet(SDL_Renderer* renderer)
|
||||
// [NUEVO] Brightness específic per bales
|
||||
brightness_ = Defaults::Brightness::BALA;
|
||||
|
||||
// [NUEVO] Carregar forma compartida des de fitxer
|
||||
// [NUEVO] Carregar shape compartida des de fitxer
|
||||
shape_ = Graphics::ShapeLoader::load("bullet.shp");
|
||||
|
||||
if (!shape_ || !shape_->es_valida()) {
|
||||
std::cerr << "[Bullet] Error: no s'ha pogut carregar bullet.shp" << '\n';
|
||||
if (!shape_ || !shape_->isValid()) {
|
||||
std::cerr << "[Bullet] Error: no s'ha pogut load bullet.shp" << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,18 +43,18 @@ void Bullet::init() {
|
||||
grace_timer_ = 0.0F;
|
||||
}
|
||||
|
||||
void Bullet::disparar(const Vec2& posicio, float angle, uint8_t owner_id) {
|
||||
// Activar bala i posicionar-la a la nau
|
||||
void Bullet::disparar(const Vec2& position, float angle, uint8_t owner_id) {
|
||||
// Activar bullet i posicionar-la a la ship
|
||||
// Basat en joc_asteroides.cpp línies 188-200
|
||||
|
||||
// Activar bala
|
||||
// Activar bullet
|
||||
esta_ = true;
|
||||
|
||||
// Posició inicial = centre de la nau
|
||||
center_.x = posicio.x;
|
||||
center_.y = posicio.y;
|
||||
// Posició inicial = centre de la ship
|
||||
center_.x = position.x;
|
||||
center_.y = position.y;
|
||||
|
||||
// Angle = angle de la nau (dispara en la direcció que apunta)
|
||||
// Angle = angle de la ship (dispara en la direcció que apunta)
|
||||
angle_ = angle;
|
||||
|
||||
// Almacenar propietario (0=P1, 1=P2)
|
||||
@@ -92,12 +92,12 @@ void Bullet::draw() const {
|
||||
}
|
||||
|
||||
void Bullet::mou(float delta_time) {
|
||||
// Moviment rectilini de la bala
|
||||
// Moviment rectilini de la bullet
|
||||
// Basat en el codi Pascal original: procedure mou_bales
|
||||
// Copiat EXACTAMENT de joc_asteroides.cpp línies 396-419
|
||||
|
||||
// Calcular nova posició (moviment polar time-based)
|
||||
// velocitat ja està en px/s (140 px/s), només cal multiplicar per delta_time
|
||||
// velocity ja està en px/s (140 px/s), només cal multiplicar per delta_time
|
||||
float velocitat_efectiva = velocity_ * delta_time;
|
||||
|
||||
// Calcular desplaçament (angle-PI/2 perquè angle=0 apunta amunt)
|
||||
@@ -109,7 +109,7 @@ void Bullet::mou(float delta_time) {
|
||||
center_.x += dx;
|
||||
|
||||
// Desactivar si surt de la zona de joc (no rebota com els ORNIs)
|
||||
// CORRECCIÓ: Usar límits segurs amb radi de la bala
|
||||
// CORRECCIÓ: Usar límits segurs amb radi de la bullet
|
||||
float min_x;
|
||||
float max_x;
|
||||
float min_y;
|
||||
|
||||
Reference in New Issue
Block a user