ae5cc1cfb4
Tots els tipus d'entitat passen del catala a l'angles seguint el
.clang-tidy del projecte (tipus en CamelCase, metodes en camelBack,
membres en lower_case amb sufix _).
Renames de tipus:
- Entitat -> Entity (core/entities/entity.hpp)
- Nau -> Ship (game/entities/ship.{hpp,cpp})
- Enemic -> Enemy (game/entities/enemy.{hpp,cpp})
- Bala -> Bullet (game/entities/bullet.{hpp,cpp})
- TipusEnemic -> EnemyType
- AnimacioEnemic -> EnemyAnimation
Metodes virtuals (s'aplica a tot el codi, no nomes a entitats):
- actualitzar -> update
- dibuixar -> draw
- inicialitzar -> init
- processar_input -> processInput
- esta_actiu -> isActive
- es_collidable -> isCollidable
- get_collision_radius -> getCollisionRadius
Getters comuns:
- get_centre -> getCenter
- get_angle -> getAngle
- get_brightness -> getBrightness
- get_forma -> getShape
Metodes especifics:
- esta_viva -> isAlive
- esta_tocada -> isHit
- es_invulnerable -> isInvulnerable
- get_velocitat_vector -> getVelocityVector
- set_centre -> setCenter
- marcar_tocada -> markHit
- aplicar_fisica -> applyPhysics
- get_tipus -> getType
Camps privats:
- centre_ -> center_
- velocitat_ -> velocity_
- forma_ -> shape_
- esta_tocada_ -> is_hit_
- tipus_ -> type_
L'import d'audio/input d'AEEA quedara coherent (mateix estil).
Diff net: 30 fitxers, +437/-437 (la majoria es renames simetrics).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
// nau.hpp - Classe per a la nave del jugador
|
|
// © 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);
|
|
};
|