refactor(enemy): renombra drotacio/rotacio/FACTOR_HERENCIA a anglès
This commit is contained in:
@@ -170,10 +170,10 @@ namespace Effects {
|
||||
|
||||
// FASE 1: Aplicar herència i variació
|
||||
float factor_herencia =
|
||||
Defaults::Physics::Debris::FACTOR_HERENCIA_MIN +
|
||||
Defaults::Physics::Debris::INHERITANCE_FACTOR_MIN +
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
(Defaults::Physics::Debris::FACTOR_HERENCIA_MAX -
|
||||
Defaults::Physics::Debris::FACTOR_HERENCIA_MIN));
|
||||
(Defaults::Physics::Debris::INHERITANCE_FACTOR_MAX -
|
||||
Defaults::Physics::Debris::INHERITANCE_FACTOR_MIN));
|
||||
float velocitat_ang_heretada = velocitat_angular * factor_herencia;
|
||||
float variacio = ((std::rand() / static_cast<float>(RAND_MAX)) * 0.2F) - 0.1F;
|
||||
velocitat_ang_heretada *= (1.0F + variacio);
|
||||
@@ -213,10 +213,10 @@ namespace Effects {
|
||||
|
||||
// Rotación visual aleatòria (factor = 0.0 o sin velocidad angular)
|
||||
debris.velocitat_rot_visual =
|
||||
Defaults::Physics::Debris::ROTACIO_MIN +
|
||||
Defaults::Physics::Debris::ROTATION_MIN +
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
(Defaults::Physics::Debris::ROTACIO_MAX -
|
||||
Defaults::Physics::Debris::ROTACIO_MIN));
|
||||
(Defaults::Physics::Debris::ROTATION_MAX -
|
||||
Defaults::Physics::Debris::ROTATION_MIN));
|
||||
|
||||
// 50% probabilitat de rotación en sentit contrari
|
||||
if (std::rand() % 2 == 0) {
|
||||
|
||||
@@ -58,24 +58,24 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
|
||||
const char* shape_file = nullptr;
|
||||
float base_speed = 0.0F;
|
||||
float drotacio_min = 0.0F;
|
||||
float drotacio_max = 0.0F;
|
||||
float rotation_delta_min = 0.0F;
|
||||
float rotation_delta_max = 0.0F;
|
||||
float type_mass = Defaults::Enemies::Body::DEFAULT_MASS;
|
||||
|
||||
switch (type_) {
|
||||
case EnemyType::PENTAGON:
|
||||
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Pentagon::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Pentagon::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Pentagon::DROTACIO_MAX;
|
||||
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
||||
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
||||
type_mass = Defaults::Enemies::Pentagon::MASS;
|
||||
break;
|
||||
|
||||
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;
|
||||
rotation_delta_min = Defaults::Enemies::Square::ROTATION_DELTA_MIN;
|
||||
rotation_delta_max = Defaults::Enemies::Square::ROTATION_DELTA_MAX;
|
||||
type_mass = Defaults::Enemies::Square::MASS;
|
||||
tracking_timer_ = 0.0F;
|
||||
break;
|
||||
@@ -83,8 +83,8 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
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;
|
||||
rotation_delta_min = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MIN;
|
||||
rotation_delta_max = Defaults::Enemies::Pinwheel::ROTATION_DELTA_MAX;
|
||||
type_mass = Defaults::Enemies::Pinwheel::MASS;
|
||||
break;
|
||||
|
||||
@@ -93,8 +93,8 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
<< static_cast<int>(type_) << "), usando PENTAGON\n";
|
||||
shape_file = Defaults::Enemies::Pentagon::SHAPE_FILE;
|
||||
base_speed = Defaults::Enemies::Pentagon::VELOCITAT;
|
||||
drotacio_min = Defaults::Enemies::Pentagon::DROTACIO_MIN;
|
||||
drotacio_max = Defaults::Enemies::Pentagon::DROTACIO_MAX;
|
||||
rotation_delta_min = Defaults::Enemies::Pentagon::ROTATION_DELTA_MIN;
|
||||
rotation_delta_max = Defaults::Enemies::Pentagon::ROTATION_DELTA_MAX;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -152,15 +152,15 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
body_.clearAccumulators();
|
||||
|
||||
// Rotación visual aleatoria (independiente del body)
|
||||
const float DROTACIO_RANGE = drotacio_max - drotacio_min;
|
||||
drotacio_ = drotacio_min + ((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * DROTACIO_RANGE);
|
||||
rotacio_ = 0.0F;
|
||||
const float ROTATION_DELTA_RANGE = rotation_delta_max - rotation_delta_min;
|
||||
rotation_delta_ = rotation_delta_min + ((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * ROTATION_DELTA_RANGE);
|
||||
rotation_ = 0.0F;
|
||||
|
||||
// Estado de animación
|
||||
animacio_ = EnemyAnimation();
|
||||
animacio_.drotacio_base = drotacio_;
|
||||
animacio_.drotacio_objetivo = drotacio_;
|
||||
animacio_.drotacio_t = 1.0F;
|
||||
animacio_.rotation_delta_base = rotation_delta_;
|
||||
animacio_.rotation_delta_target = rotation_delta_;
|
||||
animacio_.rotation_delta_t = 1.0F;
|
||||
|
||||
// Invulnerabilidad post-spawn
|
||||
timer_invulnerabilitat_ = Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
@@ -222,7 +222,7 @@ void Enemy::update(float delta_time) {
|
||||
updateAnimation(delta_time);
|
||||
|
||||
// Rotación visual (decoración, no afecta movimiento)
|
||||
rotacio_ += drotacio_ * delta_time;
|
||||
rotation_ += rotation_delta_ * delta_time;
|
||||
}
|
||||
|
||||
void Enemy::postUpdate(float /*delta_time*/) {
|
||||
@@ -260,7 +260,7 @@ void Enemy::draw() const {
|
||||
}
|
||||
}
|
||||
|
||||
Rendering::renderShape(renderer_, shape_, center_, rotacio_, SCALE, 1.0F, brightness_, color);
|
||||
Rendering::renderShape(renderer_, shape_, center_, rotation_, SCALE, 1.0F, brightness_, color);
|
||||
}
|
||||
|
||||
void Enemy::destroy() {
|
||||
@@ -357,9 +357,9 @@ void Enemy::behaviorPinwheel(float /*delta_time*/) {
|
||||
const Vec2 TO_SHIP = *ship_position_ - center_;
|
||||
const float DIST = TO_SHIP.length();
|
||||
if (DIST < Defaults::Enemies::Pinwheel::PROXIMITY_DISTANCE) {
|
||||
drotacio_ = animacio_.drotacio_base * Defaults::Enemies::Pinwheel::DROTACIO_PROXIMITY_MULTIPLIER;
|
||||
rotation_delta_ = animacio_.rotation_delta_base * Defaults::Enemies::Pinwheel::ROTATION_DELTA_PROXIMITY_MULTIPLIER;
|
||||
} else {
|
||||
drotacio_ = animacio_.drotacio_base;
|
||||
rotation_delta_ = animacio_.rotation_delta_base;
|
||||
}
|
||||
}
|
||||
// Movimiento lineal puro: el world se encarga de integrar y rebotar.
|
||||
@@ -403,34 +403,34 @@ void Enemy::updatePulse(float delta_time) {
|
||||
}
|
||||
|
||||
void Enemy::updateRotationAcceleration(float delta_time) {
|
||||
if (animacio_.drotacio_t < 1.0F) {
|
||||
animacio_.drotacio_t += delta_time / animacio_.drotacio_duracio;
|
||||
if (animacio_.drotacio_t >= 1.0F) {
|
||||
animacio_.drotacio_t = 1.0F;
|
||||
animacio_.drotacio_base = animacio_.drotacio_objetivo;
|
||||
drotacio_ = animacio_.drotacio_base;
|
||||
if (animacio_.rotation_delta_t < 1.0F) {
|
||||
animacio_.rotation_delta_t += delta_time / animacio_.rotation_delta_duration;
|
||||
if (animacio_.rotation_delta_t >= 1.0F) {
|
||||
animacio_.rotation_delta_t = 1.0F;
|
||||
animacio_.rotation_delta_base = animacio_.rotation_delta_target;
|
||||
rotation_delta_ = animacio_.rotation_delta_base;
|
||||
} else {
|
||||
const float T = animacio_.drotacio_t;
|
||||
const float T = animacio_.rotation_delta_t;
|
||||
const float SMOOTH_T = T * T * (3.0F - (2.0F * T));
|
||||
const float INITIAL = animacio_.drotacio_base;
|
||||
const float TARGET = animacio_.drotacio_objetivo;
|
||||
drotacio_ = INITIAL + ((TARGET - INITIAL) * SMOOTH_T);
|
||||
const float INITIAL = animacio_.rotation_delta_base;
|
||||
const float TARGET = animacio_.rotation_delta_target;
|
||||
rotation_delta_ = INITIAL + ((TARGET - INITIAL) * SMOOTH_T);
|
||||
}
|
||||
} else {
|
||||
const float RAND_VAL = static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX);
|
||||
const float TRIGGER_PROB = Defaults::Enemies::Animation::ROTACIO_ACCEL_TRIGGER_PROB * delta_time;
|
||||
const float TRIGGER_PROB = Defaults::Enemies::Animation::ROTATION_ACCEL_TRIGGER_PROB * delta_time;
|
||||
if (RAND_VAL < TRIGGER_PROB) {
|
||||
animacio_.drotacio_t = 0.0F;
|
||||
animacio_.rotation_delta_t = 0.0F;
|
||||
|
||||
const float MULT_RANGE = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MAX -
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN;
|
||||
const float MULTIPLIER = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN +
|
||||
const float MULT_RANGE = Defaults::Enemies::Animation::ROTATION_ACCEL_MULTIPLIER_MAX -
|
||||
Defaults::Enemies::Animation::ROTATION_ACCEL_MULTIPLIER_MIN;
|
||||
const float MULTIPLIER = Defaults::Enemies::Animation::ROTATION_ACCEL_MULTIPLIER_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * MULT_RANGE);
|
||||
animacio_.drotacio_objetivo = animacio_.drotacio_base * MULTIPLIER;
|
||||
animacio_.rotation_delta_target = animacio_.rotation_delta_base * MULTIPLIER;
|
||||
|
||||
const float DUR_RANGE = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN;
|
||||
animacio_.drotacio_duracio = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN +
|
||||
const float DUR_RANGE = Defaults::Enemies::Animation::ROTATION_ACCEL_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::ROTATION_ACCEL_DURACIO_MIN;
|
||||
animacio_.rotation_delta_duration = Defaults::Enemies::Animation::ROTATION_ACCEL_DURACIO_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * DUR_RANGE);
|
||||
}
|
||||
}
|
||||
@@ -465,7 +465,7 @@ auto Enemy::getBaseVelocity() const -> float {
|
||||
}
|
||||
|
||||
auto Enemy::getBaseRotation() const -> float {
|
||||
return animacio_.drotacio_base != 0.0F ? animacio_.drotacio_base : drotacio_;
|
||||
return animacio_.rotation_delta_base != 0.0F ? animacio_.rotation_delta_base : rotation_delta_;
|
||||
}
|
||||
|
||||
void Enemy::setTrackingStrength(float strength) {
|
||||
|
||||
@@ -27,10 +27,10 @@ struct EnemyAnimation {
|
||||
float pulse_time_remaining = 0.0F;
|
||||
|
||||
// Aceleración de rotación visual (modulación a largo plazo)
|
||||
float drotacio_base = 0.0F;
|
||||
float drotacio_objetivo = 0.0F;
|
||||
float drotacio_t = 0.0F;
|
||||
float drotacio_duracio = 0.0F;
|
||||
float rotation_delta_base = 0.0F;
|
||||
float rotation_delta_target = 0.0F;
|
||||
float rotation_delta_t = 0.0F;
|
||||
float rotation_delta_duration = 0.0F;
|
||||
};
|
||||
|
||||
class Enemy : public Entities::Entity {
|
||||
@@ -63,7 +63,7 @@ class Enemy : public Entities::Entity {
|
||||
void destroy();
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto getRotationDelta() const -> float { return drotacio_; }
|
||||
[[nodiscard]] auto getRotationDelta() const -> float { return rotation_delta_; }
|
||||
[[nodiscard]] auto getVelocityVector() const -> Vec2 { return body_.velocity; }
|
||||
|
||||
// Set ship position reference for tracking behavior
|
||||
@@ -79,8 +79,8 @@ class Enemy : public Entities::Entity {
|
||||
// actual del body_.velocity.
|
||||
void setVelocity(float speed);
|
||||
void setRotation(float rot) {
|
||||
drotacio_ = rot;
|
||||
animacio_.drotacio_base = rot;
|
||||
rotation_delta_ = rot;
|
||||
animacio_.rotation_delta_base = rot;
|
||||
}
|
||||
void setTrackingStrength(float strength);
|
||||
|
||||
@@ -104,8 +104,8 @@ class Enemy : public Entities::Entity {
|
||||
// Miembros específicos (heredados: renderer_, shape_, center_, angle_, brightness_, body_).
|
||||
// Inicializados en la declaración: el ctor por defecto deja al enemy en estado "inactivo
|
||||
// como pentágono", coherente con lo que harán init() o el ctor con renderer al activarlo.
|
||||
float drotacio_{0.0F}; // Velocidad angular visual (rad/s) — solo decoración, separada de body_.angular_velocity
|
||||
float rotacio_{0.0F}; // Rotación visual acumulada (no afecta movimiento)
|
||||
float rotation_delta_{0.0F}; // Velocidad angular visual (rad/s) — solo decoración, separada de body_.angular_velocity
|
||||
float rotation_{0.0F}; // Rotación visual acumulada (no afecta movimiento)
|
||||
bool esta_{false};
|
||||
|
||||
EnemyType type_{EnemyType::PENTAGON};
|
||||
|
||||
Reference in New Issue
Block a user