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>
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
// bala.hpp - Classe per a projectils de la nau
|
|
// © 1999 Visente i Sergi (versió Pascal)
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "core/defaults.hpp"
|
|
#include "core/entities/entity.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
class Bullet : public Entities::Entity {
|
|
public:
|
|
Bullet()
|
|
: Entity(nullptr) {}
|
|
Bullet(SDL_Renderer* renderer);
|
|
|
|
void init() override;
|
|
void disparar(const Vec2& posicio, float angle, uint8_t owner_id);
|
|
void update(float delta_time) override;
|
|
void draw() const override;
|
|
|
|
// Override: Interfície d'Entity
|
|
[[nodiscard]] bool isActive() const override { return esta_; }
|
|
|
|
// Override: Interfície de col·lisió
|
|
[[nodiscard]] float getCollisionRadius() const override {
|
|
return Defaults::Entities::BULLET_RADIUS;
|
|
}
|
|
[[nodiscard]] bool isCollidable() const override {
|
|
return esta_ && grace_timer_ <= 0.0F;
|
|
}
|
|
|
|
// Getters (API pública sense canvis)
|
|
[[nodiscard]] bool esta_activa() const { return esta_; }
|
|
[[nodiscard]] uint8_t get_owner_id() const { return owner_id_; }
|
|
[[nodiscard]] float get_grace_timer() const { return grace_timer_; }
|
|
void desactivar() { esta_ = false; }
|
|
|
|
private:
|
|
// Membres específics de Bullet (heretats: renderer_, shape_, center_, angle_, brightness_)
|
|
float velocity_;
|
|
bool esta_;
|
|
uint8_t owner_id_; // 0=P1, 1=P2
|
|
float grace_timer_; // Grace period timer (0.0 = vulnerable)
|
|
|
|
void mou(float delta_time);
|
|
};
|