refactor(enemy): renombra drotacio/rotacio/FACTOR_HERENCIA a anglès
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user