refactor(enemies): renombra QUADRAT/MOLINILLO a SQUARE/PINWHEEL
This commit is contained in:
1 parent
6210985548
commit
e5e3729215
13 files changed
+200
-200
No files matched your search
@@ -53,7 +53,7 @@ void Bullet::init() {
|
||||
body_.clearAccumulators();
|
||||
}
|
||||
|
||||
void Bullet::disparar(const Vec2& position, float angle, uint8_t owner_id) {
|
||||
void Bullet::fire(const Vec2& position, float angle, uint8_t owner_id) {
|
||||
// Activar bullet
|
||||
is_active_ = true;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Bullet : public Entities::Entity {
|
||||
explicit Bullet(Rendering::Renderer* renderer);
|
||||
|
||||
void init() override;
|
||||
void disparar(const Vec2& position, float angle, uint8_t owner_id);
|
||||
void fire(const Vec2& position, float angle, uint8_t owner_id);
|
||||
void update(float delta_time) override;
|
||||
void postUpdate(float delta_time) override;
|
||||
void draw() const override;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace {
|
||||
Enemy::Enemy(Rendering::Renderer* renderer)
|
||||
: Entity(renderer),
|
||||
|
||||
tracking_strength_(Defaults::Enemies::Cuadrado::TRACKING_STRENGTH) {
|
||||
tracking_strength_(Defaults::Enemies::Square::TRACKING_STRENGTH) {
|
||||
brightness_ = Defaults::Brightness::ENEMIC;
|
||||
|
||||
// Configuración del cuerpo físico — defaults para enemy genérico.
|
||||
@@ -71,21 +71,21 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
type_mass = Defaults::Enemies::Pentagon::MASS;
|
||||
break;
|
||||
|
||||
case EnemyType::QUADRAT:
|
||||
shape_file = Defaults::Enemies::Cuadrado::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Cuadrado::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Cuadrado::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Cuadrado::DROTACIO_MAX;
|
||||
type_mass = Defaults::Enemies::Cuadrado::MASS;
|
||||
case EnemyType::SQUARE:
|
||||
shape_file = Defaults::Enemies::Square::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Square::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Square::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Square::DROTACIO_MAX;
|
||||
type_mass = Defaults::Enemies::Square::MASS;
|
||||
tracking_timer_ = 0.0F;
|
||||
break;
|
||||
|
||||
case EnemyType::MOLINILLO:
|
||||
shape_file = Defaults::Enemies::Molinillo::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Molinillo::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Molinillo::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Molinillo::DROTACIO_MAX;
|
||||
type_mass = Defaults::Enemies::Molinillo::MASS;
|
||||
case EnemyType::PINWHEEL:
|
||||
shape_file = Defaults::Enemies::Pinwheel::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Pinwheel::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Pinwheel::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Pinwheel::DROTACIO_MAX;
|
||||
type_mass = Defaults::Enemies::Pinwheel::MASS;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -209,11 +209,11 @@ void Enemy::update(float delta_time) {
|
||||
case EnemyType::PENTAGON:
|
||||
behaviorPentagon(delta_time);
|
||||
break;
|
||||
case EnemyType::QUADRAT:
|
||||
behaviorQuadrat(delta_time);
|
||||
case EnemyType::SQUARE:
|
||||
behaviorSquare(delta_time);
|
||||
break;
|
||||
case EnemyType::MOLINILLO:
|
||||
behaviorMolinillo(delta_time);
|
||||
case EnemyType::PINWHEEL:
|
||||
behaviorPinwheel(delta_time);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -242,11 +242,11 @@ void Enemy::draw() const {
|
||||
case EnemyType::PENTAGON:
|
||||
color = Defaults::Palette::PENTAGON;
|
||||
break;
|
||||
case EnemyType::QUADRAT:
|
||||
color = Defaults::Palette::QUADRAT;
|
||||
case EnemyType::SQUARE:
|
||||
color = Defaults::Palette::SQUARE;
|
||||
break;
|
||||
case EnemyType::MOLINILLO:
|
||||
color = Defaults::Palette::MOLINILLO;
|
||||
case EnemyType::PINWHEEL:
|
||||
color = Defaults::Palette::PINWHEEL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void Enemy::draw() const {
|
||||
Rendering::renderShape(renderer_, shape_, center_, rotacio_, SCALE, 1.0F, brightness_, color);
|
||||
}
|
||||
|
||||
void Enemy::destruir() {
|
||||
void Enemy::destroy() {
|
||||
esta_ = false;
|
||||
body_.velocity = Vec2{};
|
||||
body_.angular_velocity = 0.0F;
|
||||
@@ -273,7 +273,7 @@ void Enemy::destruir() {
|
||||
last_hit_by_ = 0xFF;
|
||||
}
|
||||
|
||||
void Enemy::herir(uint8_t shooter_id) {
|
||||
void Enemy::hurt(uint8_t shooter_id) {
|
||||
wounded_timer_ = Defaults::Enemies::Wounded::DURATION;
|
||||
last_hit_by_ = shooter_id;
|
||||
// El so HIT ara el reprodueix la bala quan es trenca en debris
|
||||
@@ -320,12 +320,12 @@ void Enemy::behaviorPentagon(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// QUADRAT: tracking discreto cada TRACKING_INTERVAL. Ajusta dirección
|
||||
// SQUARE: tracking discreto cada TRACKING_INTERVAL. Ajusta dirección
|
||||
// hacia el ship mezclando con tracking_strength_.
|
||||
void Enemy::behaviorQuadrat(float delta_time) {
|
||||
void Enemy::behaviorSquare(float delta_time) {
|
||||
tracking_timer_ += delta_time;
|
||||
|
||||
if (tracking_timer_ >= Defaults::Enemies::Cuadrado::TRACKING_INTERVAL && ship_position_ != nullptr) {
|
||||
if (tracking_timer_ >= Defaults::Enemies::Square::TRACKING_INTERVAL && ship_position_ != nullptr) {
|
||||
tracking_timer_ = 0.0F;
|
||||
|
||||
const Vec2 TO_SHIP = *ship_position_ - center_;
|
||||
@@ -348,16 +348,16 @@ void Enemy::behaviorQuadrat(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// MOLINILLO: movimiento recto + boost de rotación visual cerca del ship.
|
||||
// PINWHEEL: movimiento recto + boost de rotación visual cerca del ship.
|
||||
// Sin tracking — solo cambios de dirección raros (igual que Pentagon pero
|
||||
// con probabilidad mucho menor).
|
||||
void Enemy::behaviorMolinillo(float /*delta_time*/) {
|
||||
void Enemy::behaviorPinwheel(float /*delta_time*/) {
|
||||
// Boost de rotación visual por proximidad al ship
|
||||
if (ship_position_ != nullptr) {
|
||||
const Vec2 TO_SHIP = *ship_position_ - center_;
|
||||
const float DIST = TO_SHIP.length();
|
||||
if (DIST < Defaults::Enemies::Molinillo::PROXIMITY_DISTANCE) {
|
||||
drotacio_ = animacio_.drotacio_base * Defaults::Enemies::Molinillo::DROTACIO_PROXIMITY_MULTIPLIER;
|
||||
if (DIST < Defaults::Enemies::Pinwheel::PROXIMITY_DISTANCE) {
|
||||
drotacio_ = animacio_.drotacio_base * Defaults::Enemies::Pinwheel::DROTACIO_PROXIMITY_MULTIPLIER;
|
||||
} else {
|
||||
drotacio_ = animacio_.drotacio_base;
|
||||
}
|
||||
@@ -455,10 +455,10 @@ auto Enemy::getBaseVelocity() const -> float {
|
||||
switch (type_) {
|
||||
case EnemyType::PENTAGON:
|
||||
return Defaults::Enemies::Pentagon::VELOCITAT;
|
||||
case EnemyType::QUADRAT:
|
||||
return Defaults::Enemies::Cuadrado::VELOCITAT;
|
||||
case EnemyType::MOLINILLO:
|
||||
return Defaults::Enemies::Molinillo::VELOCITAT;
|
||||
case EnemyType::SQUARE:
|
||||
return Defaults::Enemies::Square::VELOCITAT;
|
||||
case EnemyType::PINWHEEL:
|
||||
return Defaults::Enemies::Pinwheel::VELOCITAT;
|
||||
default:
|
||||
return Defaults::Enemies::Pentagon::VELOCITAT;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ auto Enemy::getBaseRotation() const -> float {
|
||||
}
|
||||
|
||||
void Enemy::setTrackingStrength(float strength) {
|
||||
if (type_ == EnemyType::QUADRAT) {
|
||||
if (type_ == EnemyType::SQUARE) {
|
||||
tracking_strength_ = strength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
// Tipo de enemy
|
||||
enum class EnemyType : uint8_t {
|
||||
PENTAGON = 0, // Pentágono esquivador (zigzag)
|
||||
QUADRAT = 1, // Cuadrado perseguidor (tracks ship)
|
||||
MOLINILLO = 2 // Molinillo agresivo (rápido, girando)
|
||||
SQUARE = 1, // Square perseguidor (tracks ship)
|
||||
PINWHEEL = 2 // Molinillo agresivo (rápido, girando)
|
||||
};
|
||||
|
||||
// Estado de animación (palpitación + rotación acelerada)
|
||||
@@ -60,7 +60,7 @@ class Enemy : public Entities::Entity {
|
||||
}
|
||||
|
||||
// Marcar destruido (desactiva el cuerpo físicamente: radius=0)
|
||||
void destruir();
|
||||
void destroy();
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto getRotationDelta() const -> float { return drotacio_; }
|
||||
@@ -90,7 +90,7 @@ class Enemy : public Entities::Entity {
|
||||
|
||||
// Estado "herido": entre primer impacto de bala y explosión diferida.
|
||||
// shooter_id: id del jugador que herí; 0xFF = sin atribución (cadena, etc.).
|
||||
void herir(uint8_t shooter_id = 0xFF);
|
||||
void hurt(uint8_t shooter_id = 0xFF);
|
||||
[[nodiscard]] auto isWounded() const -> bool { return wounded_timer_ > 0.0F; }
|
||||
[[nodiscard]] auto getWoundedTimer() const -> float { return wounded_timer_; }
|
||||
[[nodiscard]] auto woundExpiredThisFrame() const -> bool { return wound_expired_this_frame_; }
|
||||
@@ -130,8 +130,8 @@ class Enemy : public Entities::Entity {
|
||||
void updatePalpitation(float delta_time);
|
||||
void updateRotationAcceleration(float delta_time);
|
||||
void behaviorPentagon(float delta_time);
|
||||
void behaviorQuadrat(float delta_time);
|
||||
void behaviorMolinillo(float delta_time);
|
||||
void behaviorSquare(float delta_time);
|
||||
void behaviorPinwheel(float delta_time);
|
||||
[[nodiscard]] auto computeCurrentScale() const -> float;
|
||||
// Estático: solo opera sobre ship_pos pasado; no consulta estado del enemy.
|
||||
static auto attemptSafeSpawn(const Vec2& ship_pos, float& out_x, float& out_y) -> bool;
|
||||
|
||||
@@ -180,7 +180,7 @@ void Ship::draw() const {
|
||||
Rendering::renderShape(renderer_, shape_, center_, angle_, SCALE, 1.0F, brightness_, color);
|
||||
}
|
||||
|
||||
void Ship::herir() {
|
||||
void Ship::hurt() {
|
||||
hurt_timer_ = Defaults::Ship::Hurt::DURATION;
|
||||
Audio::get()->playSound(Defaults::Sound::HURT, Audio::Group::GAME);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class Ship : public Entities::Entity {
|
||||
}
|
||||
|
||||
// Estat "ferit": primera col·lisió amb enemic dispara HURT; segona durant HURT mata.
|
||||
void herir();
|
||||
void hurt();
|
||||
[[nodiscard]] auto isHurt() const -> bool { return hurt_timer_ > 0.0F; }
|
||||
[[nodiscard]] auto getHurtTimer() const -> float { return hurt_timer_; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user