Files
orni-attack/source/game/entities/ship.hpp
T
JailDesigner 7ee359b910 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>
2026-05-19 11:44:45 +02:00

63 lines
2.1 KiB
C++

// ship.hpp - Classe per a la nave del player
// © 1999 Visente i Sergi (versió Pascal)
// © 2025 Port a C++20 amb SDL3
#pragma once
#include <SDL3/SDL.h>
#include <cmath>
#include <cstdint>
#include "core/defaults.hpp"
#include "core/entities/entity.hpp"
#include "core/types.hpp"
#include "game/constants.hpp"
class Ship : public Entities::Entity {
public:
Ship()
: Entity(nullptr) {}
Ship(SDL_Renderer* renderer, const char* shape_file = "ship.shp");
void init() override { init(nullptr, false); }
void init(const Vec2* spawn_point, bool activar_invulnerabilitat = false);
void processInput(float delta_time, uint8_t player_id);
void update(float delta_time) override;
void draw() const override;
// Override: Interfície d'Entity
[[nodiscard]] bool isActive() const override { return !is_hit_; }
// Override: Interfície de col·lisió
[[nodiscard]] float getCollisionRadius() const override {
return Defaults::Entities::SHIP_RADIUS;
}
[[nodiscard]] bool isCollidable() const override {
return !is_hit_ && invulnerable_timer_ <= 0.0F;
}
// Getters (API pública sense canvis)
[[nodiscard]] bool isAlive() const { return !is_hit_; }
[[nodiscard]] bool isHit() const { return is_hit_; }
[[nodiscard]] bool isInvulnerable() const { return invulnerable_timer_ > 0.0F; }
[[nodiscard]] Vec2 getVelocityVector() const {
return {
.x = velocity_ * std::cos(angle_ - (Constants::PI / 2.0F)),
.y = velocity_ * std::sin(angle_ - (Constants::PI / 2.0F))};
}
// Setters
void setCenter(const Vec2& nou_centre) { center_ = nou_centre; }
// Col·lisions (Fase 10)
void markHit() { is_hit_ = true; }
private:
// Membres específics de Ship (heretats: renderer_, shape_, center_, angle_, brightness_)
float velocity_; // Velocitat (px/s)
bool is_hit_;
float invulnerable_timer_; // 0.0f = vulnerable, >0.0f = invulnerable
void applyPhysics(float delta_time);
};