b746578bc8
Sustituye en bloque las cabeceras de los archivos por una sola línea de copyright. Cero rastro de "Visente", "Sergi" o "1999" en el árbol del proyecto. Se eliminan también las variantes "© 2025 Port a C++20", "© 2025 Port a C++20 con SDL3" y "© 2025 Orni Attack" (con todas sus colas descriptivas como "Arquitectura de entidades" o "Sistema de física"), que en este punto eran ruido histórico. Aplicado con un par de sed (find -type f, excluyendo source/external y source/legacy): 1. \|^// © 1999 Visente i Sergi (versión Pascal)$|d 2. s|^// © 2025 (Port a C++20.*|Orni Attack.*)$|// © 2026 JailDesigner| Verificado: la única variante de cabecera tras el sweep es "// © 2026 JailDesigner". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
// ship.hpp - Clase para la nave del player
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "core/defaults.hpp"
|
|
#include "core/entities/entity.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
class Ship : public Entities::Entity {
|
|
public:
|
|
Ship()
|
|
: Entity(nullptr) {}
|
|
Ship(Rendering::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 postUpdate(float delta_time) override;
|
|
void draw() const override;
|
|
|
|
// Override: Interfaz de Entity
|
|
[[nodiscard]] auto isActive() const -> bool override { return !is_hit_; }
|
|
|
|
// Override: Interfaz de colisión
|
|
[[nodiscard]] auto getCollisionRadius() const -> float override {
|
|
return Defaults::Entities::SHIP_RADIUS;
|
|
}
|
|
[[nodiscard]] auto isCollidable() const -> bool override {
|
|
return !is_hit_ && invulnerable_timer_ <= 0.0F;
|
|
}
|
|
|
|
// Getters (API pública sin cambios)
|
|
[[nodiscard]] auto isAlive() const -> bool { return !is_hit_; }
|
|
[[nodiscard]] auto isHit() const -> bool { return is_hit_; }
|
|
[[nodiscard]] auto isInvulnerable() const -> bool { return invulnerable_timer_ > 0.0F; }
|
|
// Velocidad como vector cartesiano (ahora viene directa del body_).
|
|
[[nodiscard]] auto getVelocityVector() const -> Vec2 { return body_.velocity; }
|
|
// Velocidad escalar (utilidad para draw y debugging).
|
|
[[nodiscard]] auto getSpeed() const -> float { return body_.velocity.length(); }
|
|
|
|
// Setters
|
|
void setCenter(const Vec2& nou_centre) {
|
|
center_ = nou_centre;
|
|
body_.position = nou_centre;
|
|
}
|
|
|
|
// Colisiones
|
|
void markHit() {
|
|
is_hit_ = true;
|
|
body_.velocity = Vec2{}; // Detener al morir
|
|
}
|
|
|
|
private:
|
|
// Miembros específicos de Ship (heredados: renderer_, shape_, center_, angle_, brightness_, body_)
|
|
bool is_hit_;
|
|
float invulnerable_timer_; // 0.0f = vulnerable, >0.0f = invulnerable
|
|
};
|