refactor(enemy): renombra palpitacio* a pulse*
This commit is contained in:
@@ -54,13 +54,13 @@ namespace Defaults::Enemies {
|
||||
// Animation parameters (shared)
|
||||
namespace Animation {
|
||||
// Palpitation
|
||||
constexpr float PALPITACIO_TRIGGER_PROB = 0.01F; // 1% chance per second
|
||||
constexpr float PALPITACIO_DURACIO_MIN = 1.0F; // Min duration (seconds)
|
||||
constexpr float PALPITACIO_DURACIO_MAX = 3.0F; // Max duration (seconds)
|
||||
constexpr float PALPITACIO_AMPLITUD_MIN = 0.08F; // Min scale variation
|
||||
constexpr float PALPITACIO_AMPLITUD_MAX = 0.20F; // Max scale variation
|
||||
constexpr float PALPITACIO_FREQ_MIN = 1.5F; // Min frequency (Hz)
|
||||
constexpr float PALPITACIO_FREQ_MAX = 3.0F; // Max frequency (Hz)
|
||||
constexpr float PULSE_TRIGGER_PROB = 0.01F; // 1% chance per second
|
||||
constexpr float PULSE_DURACIO_MIN = 1.0F; // Min duration (seconds)
|
||||
constexpr float PULSE_DURACIO_MAX = 3.0F; // Max duration (seconds)
|
||||
constexpr float PULSE_AMPLITUD_MIN = 0.08F; // Min scale variation
|
||||
constexpr float PULSE_AMPLITUD_MAX = 0.20F; // Max scale variation
|
||||
constexpr float PULSE_FREQ_MIN = 1.5F; // Min frequency (Hz)
|
||||
constexpr float PULSE_FREQ_MAX = 3.0F; // Max frequency (Hz)
|
||||
|
||||
// Rotation acceleration
|
||||
constexpr float ROTACIO_ACCEL_TRIGGER_PROB = 0.02F; // 2% chance per second [4x more frequent]
|
||||
|
||||
@@ -366,37 +366,37 @@ void Enemy::behaviorPinwheel(float /*delta_time*/) {
|
||||
}
|
||||
|
||||
void Enemy::updateAnimation(float delta_time) {
|
||||
updatePalpitation(delta_time);
|
||||
updatePulse(delta_time);
|
||||
updateRotationAcceleration(delta_time);
|
||||
}
|
||||
|
||||
void Enemy::updatePalpitation(float delta_time) {
|
||||
if (animacio_.palpitacio_activa) {
|
||||
animacio_.palpitacio_fase += 2.0F * Constants::PI * animacio_.palpitacio_frequencia * delta_time;
|
||||
animacio_.palpitacio_temps_restant -= delta_time;
|
||||
if (animacio_.palpitacio_temps_restant <= 0.0F) {
|
||||
animacio_.palpitacio_activa = false;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
const float RAND_VAL = static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX);
|
||||
const float TRIGGER_PROB = Defaults::Enemies::Animation::PALPITACIO_TRIGGER_PROB * delta_time;
|
||||
const float TRIGGER_PROB = Defaults::Enemies::Animation::PULSE_TRIGGER_PROB * delta_time;
|
||||
if (RAND_VAL < TRIGGER_PROB) {
|
||||
animacio_.palpitacio_activa = true;
|
||||
animacio_.palpitacio_fase = 0.0F;
|
||||
animacio_.pulse_active = true;
|
||||
animacio_.pulse_phase = 0.0F;
|
||||
|
||||
const float FREQ_RANGE = Defaults::Enemies::Animation::PALPITACIO_FREQ_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN;
|
||||
animacio_.palpitacio_frequencia = Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN +
|
||||
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 +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * FREQ_RANGE);
|
||||
|
||||
const float AMP_RANGE = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN;
|
||||
animacio_.palpitacio_amplitud = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN +
|
||||
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 +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * AMP_RANGE);
|
||||
|
||||
const float DUR_RANGE = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN;
|
||||
animacio_.palpitacio_temps_restant = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN +
|
||||
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 +
|
||||
((static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)) * DUR_RANGE);
|
||||
}
|
||||
}
|
||||
@@ -445,8 +445,8 @@ auto Enemy::computeCurrentScale() const -> float {
|
||||
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_.palpitacio_activa) {
|
||||
scale += animacio_.palpitacio_amplitud * std::sin(animacio_.palpitacio_fase);
|
||||
} else if (animacio_.pulse_active) {
|
||||
scale += animacio_.pulse_amplitude * std::sin(animacio_.pulse_phase);
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ enum class EnemyType : uint8_t {
|
||||
// Estado de animación (palpitación + rotación acelerada)
|
||||
struct EnemyAnimation {
|
||||
// Palpitación (efecto respiración)
|
||||
bool palpitacio_activa = false;
|
||||
float palpitacio_fase = 0.0F;
|
||||
float palpitacio_frequencia = 2.0F;
|
||||
float palpitacio_amplitud = 0.15F;
|
||||
float palpitacio_temps_restant = 0.0F;
|
||||
bool pulse_active = false;
|
||||
float pulse_phase = 0.0F;
|
||||
float pulse_frequency = 2.0F;
|
||||
float pulse_amplitude = 0.15F;
|
||||
float pulse_time_remaining = 0.0F;
|
||||
|
||||
// Aceleración de rotación visual (modulación a largo plazo)
|
||||
float drotacio_base = 0.0F;
|
||||
@@ -127,7 +127,7 @@ class Enemy : public Entities::Entity {
|
||||
|
||||
// Métodos privados
|
||||
void updateAnimation(float delta_time);
|
||||
void updatePalpitation(float delta_time);
|
||||
void updatePulse(float delta_time);
|
||||
void updateRotationAcceleration(float delta_time);
|
||||
void behaviorPentagon(float delta_time);
|
||||
void behaviorSquare(float delta_time);
|
||||
|
||||
Reference in New Issue
Block a user