refactor(enemy): renombra esta_/animacio_/timer_invulnerabilitat_ a anglès
This commit is contained in:
@@ -157,23 +157,23 @@ void Enemy::init(EnemyType type, const Vec2* ship_pos) {
|
||||
rotation_ = 0.0F;
|
||||
|
||||
// Estado de animación
|
||||
animacio_ = EnemyAnimation();
|
||||
animacio_.rotation_delta_base = rotation_delta_;
|
||||
animacio_.rotation_delta_target = rotation_delta_;
|
||||
animacio_.rotation_delta_t = 1.0F;
|
||||
animation_ = EnemyAnimation();
|
||||
animation_.rotation_delta_base = rotation_delta_;
|
||||
animation_.rotation_delta_target = rotation_delta_;
|
||||
animation_.rotation_delta_t = 1.0F;
|
||||
|
||||
// Invulnerabilidad post-spawn
|
||||
timer_invulnerabilitat_ = Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
invulnerability_timer_ = Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
brightness_ = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_START;
|
||||
|
||||
// Timer para próximo cambio de dirección (Pentagon)
|
||||
direction_change_timer_ = 0.0F;
|
||||
|
||||
esta_ = true;
|
||||
is_active_ = true;
|
||||
}
|
||||
|
||||
void Enemy::update(float delta_time) {
|
||||
if (!esta_) {
|
||||
if (!is_active_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ void Enemy::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Decremento de invulnerabilidad + LERP de brightness
|
||||
if (timer_invulnerabilitat_ > 0.0F) {
|
||||
timer_invulnerabilitat_ -= delta_time;
|
||||
timer_invulnerabilitat_ = std::max(timer_invulnerabilitat_, 0.0F);
|
||||
if (invulnerability_timer_ > 0.0F) {
|
||||
invulnerability_timer_ -= delta_time;
|
||||
invulnerability_timer_ = std::max(invulnerability_timer_, 0.0F);
|
||||
|
||||
const float T_INV = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
const float T_INV = invulnerability_timer_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
const float T = 1.0F - T_INV;
|
||||
const float SMOOTH_T = T * T * (3.0F - (2.0F * T));
|
||||
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_START;
|
||||
@@ -227,13 +227,13 @@ void Enemy::update(float delta_time) {
|
||||
|
||||
void Enemy::postUpdate(float /*delta_time*/) {
|
||||
// Sincronizar mirror tras la integración del world.
|
||||
if (esta_) {
|
||||
if (is_active_) {
|
||||
center_ = body_.position;
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy::draw() const {
|
||||
if (!esta_ || !shape_) {
|
||||
if (!is_active_ || !shape_) {
|
||||
return;
|
||||
}
|
||||
const float SCALE = computeCurrentScale();
|
||||
@@ -264,7 +264,7 @@ void Enemy::draw() const {
|
||||
}
|
||||
|
||||
void Enemy::destroy() {
|
||||
esta_ = false;
|
||||
is_active_ = false;
|
||||
body_.velocity = Vec2{};
|
||||
body_.angular_velocity = 0.0F;
|
||||
body_.radius = 0.0F; // No colisiona mientras está inactivo
|
||||
@@ -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) {
|
||||
rotation_delta_ = animacio_.rotation_delta_base * Defaults::Enemies::Pinwheel::ROTATION_DELTA_PROXIMITY_MULTIPLIER;
|
||||
rotation_delta_ = animation_.rotation_delta_base * Defaults::Enemies::Pinwheel::ROTATION_DELTA_PROXIMITY_MULTIPLIER;
|
||||
} else {
|
||||
rotation_delta_ = animacio_.rotation_delta_base;
|
||||
rotation_delta_ = animation_.rotation_delta_base;
|
||||
}
|
||||
}
|
||||
// Movimiento lineal puro: el world se encarga de integrar y rebotar.
|
||||
@@ -371,66 +371,66 @@ void Enemy::updateAnimation(float delta_time) {
|
||||
}
|
||||
|
||||
void Enemy::updatePulse(float delta_time) {
|
||||
if (animacio_.pulse_active) {
|
||||
animacio_.pulse_phase += 2.0F * Constants::PI * animacio_.pulse_frequency * delta_time;
|
||||
animacio_.pulse_time_remaining -= delta_time;
|
||||
if (animacio_.pulse_time_remaining <= 0.0F) {
|
||||
animacio_.pulse_active = false;
|
||||
if (animation_.pulse_active) {
|
||||
animation_.pulse_phase += 2.0F * Constants::PI * animation_.pulse_frequency * delta_time;
|
||||
animation_.pulse_time_remaining -= delta_time;
|
||||
if (animation_.pulse_time_remaining <= 0.0F) {
|
||||
animation_.pulse_active = false;
|
||||
}
|
||||
} else {
|
||||
const float RAND_VAL = static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX);
|
||||
const float TRIGGER_PROB = Defaults::Enemies::Animation::PULSE_TRIGGER_PROB * delta_time;
|
||||
if (RAND_VAL < TRIGGER_PROB) {
|
||||
animacio_.pulse_active = true;
|
||||
animacio_.pulse_phase = 0.0F;
|
||||
animation_.pulse_active = true;
|
||||
animation_.pulse_phase = 0.0F;
|
||||
|
||||
const float FREQ_RANGE = Defaults::Enemies::Animation::PULSE_FREQ_MAX -
|
||||
Defaults::Enemies::Animation::PULSE_FREQ_MIN;
|
||||
animacio_.pulse_frequency = Defaults::Enemies::Animation::PULSE_FREQ_MIN +
|
||||
animation_.pulse_frequency = Defaults::Enemies::Animation::PULSE_FREQ_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * FREQ_RANGE);
|
||||
|
||||
const float AMP_RANGE = Defaults::Enemies::Animation::PULSE_AMPLITUD_MAX -
|
||||
Defaults::Enemies::Animation::PULSE_AMPLITUD_MIN;
|
||||
animacio_.pulse_amplitude = Defaults::Enemies::Animation::PULSE_AMPLITUD_MIN +
|
||||
animation_.pulse_amplitude = Defaults::Enemies::Animation::PULSE_AMPLITUD_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * AMP_RANGE);
|
||||
|
||||
const float DUR_RANGE = Defaults::Enemies::Animation::PULSE_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::PULSE_DURACIO_MIN;
|
||||
animacio_.pulse_time_remaining = Defaults::Enemies::Animation::PULSE_DURACIO_MIN +
|
||||
animation_.pulse_time_remaining = Defaults::Enemies::Animation::PULSE_DURACIO_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * DUR_RANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Enemy::updateRotationAcceleration(float delta_time) {
|
||||
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;
|
||||
if (animation_.rotation_delta_t < 1.0F) {
|
||||
animation_.rotation_delta_t += delta_time / animation_.rotation_delta_duration;
|
||||
if (animation_.rotation_delta_t >= 1.0F) {
|
||||
animation_.rotation_delta_t = 1.0F;
|
||||
animation_.rotation_delta_base = animation_.rotation_delta_target;
|
||||
rotation_delta_ = animation_.rotation_delta_base;
|
||||
} else {
|
||||
const float T = animacio_.rotation_delta_t;
|
||||
const float T = animation_.rotation_delta_t;
|
||||
const float SMOOTH_T = T * T * (3.0F - (2.0F * T));
|
||||
const float INITIAL = animacio_.rotation_delta_base;
|
||||
const float TARGET = animacio_.rotation_delta_target;
|
||||
const float INITIAL = animation_.rotation_delta_base;
|
||||
const float TARGET = animation_.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::ROTATION_ACCEL_TRIGGER_PROB * delta_time;
|
||||
if (RAND_VAL < TRIGGER_PROB) {
|
||||
animacio_.rotation_delta_t = 0.0F;
|
||||
animation_.rotation_delta_t = 0.0F;
|
||||
|
||||
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_.rotation_delta_target = animacio_.rotation_delta_base * MULTIPLIER;
|
||||
animation_.rotation_delta_target = animation_.rotation_delta_base * MULTIPLIER;
|
||||
|
||||
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 +
|
||||
animation_.rotation_delta_duration = Defaults::Enemies::Animation::ROTATION_ACCEL_DURACIO_MIN +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * DUR_RANGE);
|
||||
}
|
||||
}
|
||||
@@ -438,15 +438,15 @@ void Enemy::updateRotationAcceleration(float delta_time) {
|
||||
|
||||
auto Enemy::computeCurrentScale() const -> float {
|
||||
float scale = 1.0F;
|
||||
if (timer_invulnerabilitat_ > 0.0F) {
|
||||
const float T_INV = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
if (invulnerability_timer_ > 0.0F) {
|
||||
const float T_INV = invulnerability_timer_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION;
|
||||
const float T = 1.0F - T_INV;
|
||||
const float SMOOTH_T = T * T * (3.0F - (2.0F * T));
|
||||
constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_START;
|
||||
constexpr float END = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_END;
|
||||
scale = START + ((END - START) * SMOOTH_T);
|
||||
} else if (animacio_.pulse_active) {
|
||||
scale += animacio_.pulse_amplitude * std::sin(animacio_.pulse_phase);
|
||||
} else if (animation_.pulse_active) {
|
||||
scale += animation_.pulse_amplitude * std::sin(animation_.pulse_phase);
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ auto Enemy::getBaseVelocity() const -> float {
|
||||
}
|
||||
|
||||
auto Enemy::getBaseRotation() const -> float {
|
||||
return animacio_.rotation_delta_base != 0.0F ? animacio_.rotation_delta_base : rotation_delta_;
|
||||
return animation_.rotation_delta_base != 0.0F ? animation_.rotation_delta_base : rotation_delta_;
|
||||
}
|
||||
|
||||
void Enemy::setTrackingStrength(float strength) {
|
||||
|
||||
Reference in New Issue
Block a user