afegit titol al TITOL
This commit is contained in:
@@ -150,7 +150,10 @@ void Enemic::comportament_pentagon(float delta_time) {
|
||||
// Obtenir límits segurs
|
||||
float min_x, max_x, min_y, max_y;
|
||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
||||
min_x, max_x, min_y, max_y);
|
||||
min_x,
|
||||
max_x,
|
||||
min_y,
|
||||
max_y);
|
||||
|
||||
// Zigzag: canvi d'angle més freqüent en tocar límits
|
||||
if (new_y >= min_y && new_y <= max_y) {
|
||||
@@ -159,7 +162,7 @@ void Enemic::comportament_pentagon(float delta_time) {
|
||||
// Probabilitat més alta de canvi d'angle
|
||||
if (static_cast<float>(std::rand()) / RAND_MAX < Defaults::Enemies::Pentagon::CANVI_ANGLE_PROB) {
|
||||
float rand_angle = (static_cast<float>(std::rand()) / RAND_MAX) *
|
||||
Defaults::Enemies::Pentagon::CANVI_ANGLE_MAX;
|
||||
Defaults::Enemies::Pentagon::CANVI_ANGLE_MAX;
|
||||
angle_ += (std::rand() % 2 == 0) ? rand_angle : -rand_angle;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +172,7 @@ void Enemic::comportament_pentagon(float delta_time) {
|
||||
} else {
|
||||
if (static_cast<float>(std::rand()) / RAND_MAX < Defaults::Enemies::Pentagon::CANVI_ANGLE_PROB) {
|
||||
float rand_angle = (static_cast<float>(std::rand()) / RAND_MAX) *
|
||||
Defaults::Enemies::Pentagon::CANVI_ANGLE_MAX;
|
||||
Defaults::Enemies::Pentagon::CANVI_ANGLE_MAX;
|
||||
angle_ += (std::rand() % 2 == 0) ? rand_angle : -rand_angle;
|
||||
}
|
||||
}
|
||||
@@ -214,7 +217,10 @@ void Enemic::comportament_quadrat(float delta_time) {
|
||||
// Obtenir límits segurs
|
||||
float min_x, max_x, min_y, max_y;
|
||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
||||
min_x, max_x, min_y, max_y);
|
||||
min_x,
|
||||
max_x,
|
||||
min_y,
|
||||
max_y);
|
||||
|
||||
// Bounce on walls (simple reflection)
|
||||
if (new_y >= min_y && new_y <= max_y) {
|
||||
@@ -260,7 +266,10 @@ void Enemic::comportament_molinillo(float delta_time) {
|
||||
// Obtenir límits segurs
|
||||
float min_x, max_x, min_y, max_y;
|
||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::ENEMY_RADIUS,
|
||||
min_x, max_x, min_y, max_y);
|
||||
min_x,
|
||||
max_x,
|
||||
min_y,
|
||||
max_y);
|
||||
|
||||
// Rare angle changes on wall hits
|
||||
if (new_y >= min_y && new_y <= max_y) {
|
||||
@@ -268,7 +277,7 @@ void Enemic::comportament_molinillo(float delta_time) {
|
||||
} else {
|
||||
if (static_cast<float>(std::rand()) / RAND_MAX < Defaults::Enemies::Molinillo::CANVI_ANGLE_PROB) {
|
||||
float rand_angle = (static_cast<float>(std::rand()) / RAND_MAX) *
|
||||
Defaults::Enemies::Molinillo::CANVI_ANGLE_MAX;
|
||||
Defaults::Enemies::Molinillo::CANVI_ANGLE_MAX;
|
||||
angle_ += (std::rand() % 2 == 0) ? rand_angle : -rand_angle;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +287,7 @@ void Enemic::comportament_molinillo(float delta_time) {
|
||||
} else {
|
||||
if (static_cast<float>(std::rand()) / RAND_MAX < Defaults::Enemies::Molinillo::CANVI_ANGLE_PROB) {
|
||||
float rand_angle = (static_cast<float>(std::rand()) / RAND_MAX) *
|
||||
Defaults::Enemies::Molinillo::CANVI_ANGLE_MAX;
|
||||
Defaults::Enemies::Molinillo::CANVI_ANGLE_MAX;
|
||||
angle_ += (std::rand() % 2 == 0) ? rand_angle : -rand_angle;
|
||||
}
|
||||
}
|
||||
@@ -313,17 +322,17 @@ void Enemic::actualitzar_palpitacio(float delta_time) {
|
||||
|
||||
// Randomize parameters
|
||||
float freq_range = Defaults::Enemies::Animation::PALPITACIO_FREQ_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN;
|
||||
Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN;
|
||||
animacio_.palpitacio_frequencia = Defaults::Enemies::Animation::PALPITACIO_FREQ_MIN +
|
||||
(static_cast<float>(std::rand()) / RAND_MAX) * freq_range;
|
||||
|
||||
float amp_range = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN;
|
||||
Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN;
|
||||
animacio_.palpitacio_amplitud = Defaults::Enemies::Animation::PALPITACIO_AMPLITUD_MIN +
|
||||
(static_cast<float>(std::rand()) / RAND_MAX) * amp_range;
|
||||
|
||||
float dur_range = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN;
|
||||
Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN;
|
||||
animacio_.palpitacio_temps_restant = Defaults::Enemies::Animation::PALPITACIO_DURACIO_MIN +
|
||||
(static_cast<float>(std::rand()) / RAND_MAX) * dur_range;
|
||||
}
|
||||
@@ -360,7 +369,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
|
||||
|
||||
// Randomize target speed (multiplier * base)
|
||||
float mult_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MAX -
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN;
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN;
|
||||
float multiplier = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MIN +
|
||||
(static_cast<float>(std::rand()) / RAND_MAX) * mult_range;
|
||||
|
||||
@@ -368,7 +377,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) {
|
||||
|
||||
// Randomize duration
|
||||
float dur_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MAX -
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN;
|
||||
Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN;
|
||||
animacio_.drotacio_duracio = Defaults::Enemies::Animation::ROTACIO_ACCEL_DURACIO_MIN +
|
||||
(static_cast<float>(std::rand()) / RAND_MAX) * dur_range;
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@
|
||||
|
||||
// Tipus d'enemic
|
||||
enum class TipusEnemic : uint8_t {
|
||||
PENTAGON = 0, // Pentàgon esquivador (zigzag)
|
||||
QUADRAT = 1, // Quadrat perseguidor (tracks ship)
|
||||
MOLINILLO = 2 // Molinillo agressiu (fast, spinning)
|
||||
PENTAGON = 0, // Pentàgon esquivador (zigzag)
|
||||
QUADRAT = 1, // Quadrat perseguidor (tracks ship)
|
||||
MOLINILLO = 2 // Molinillo agressiu (fast, spinning)
|
||||
};
|
||||
|
||||
// Estat d'animació (palpitació i rotació accelerada)
|
||||
struct AnimacioEnemic {
|
||||
// Palpitation (breathing effect)
|
||||
bool palpitacio_activa = false;
|
||||
float palpitacio_fase = 0.0f; // Phase in cycle (0.0-2π)
|
||||
float palpitacio_frequencia = 2.0f; // Hz (cycles per second)
|
||||
float palpitacio_amplitud = 0.15f; // Scale variation (±15%)
|
||||
float palpitacio_temps_restant = 0.0f; // Time remaining (seconds)
|
||||
// Palpitation (breathing effect)
|
||||
bool palpitacio_activa = false;
|
||||
float palpitacio_fase = 0.0f; // Phase in cycle (0.0-2π)
|
||||
float palpitacio_frequencia = 2.0f; // Hz (cycles per second)
|
||||
float palpitacio_amplitud = 0.15f; // Scale variation (±15%)
|
||||
float palpitacio_temps_restant = 0.0f; // Time remaining (seconds)
|
||||
|
||||
// Rotation acceleration (long-term spin modulation)
|
||||
float drotacio_base = 0.0f; // Base rotation speed (rad/s)
|
||||
float drotacio_objetivo = 0.0f; // Target rotation speed (rad/s)
|
||||
float drotacio_t = 0.0f; // Interpolation progress (0.0-1.0)
|
||||
float drotacio_duracio = 0.0f; // Duration of transition (seconds)
|
||||
// Rotation acceleration (long-term spin modulation)
|
||||
float drotacio_base = 0.0f; // Base rotation speed (rad/s)
|
||||
float drotacio_objetivo = 0.0f; // Target rotation speed (rad/s)
|
||||
float drotacio_t = 0.0f; // Interpolation progress (0.0-1.0)
|
||||
float drotacio_duracio = 0.0f; // Duration of transition (seconds)
|
||||
};
|
||||
|
||||
class Enemic {
|
||||
@@ -60,10 +60,10 @@ class Enemic {
|
||||
|
||||
// [NUEVO] Estat de la instància (separat de la geometria)
|
||||
Punt centre_;
|
||||
float angle_; // Angle de moviment
|
||||
float angle_; // Angle de moviment
|
||||
float velocitat_;
|
||||
float drotacio_; // Delta rotació visual (rad/s)
|
||||
float rotacio_; // Rotació visual acumulada
|
||||
float drotacio_; // Delta rotació visual (rad/s)
|
||||
float rotacio_; // Rotació visual acumulada
|
||||
bool esta_;
|
||||
float brightness_; // Factor de brillantor (0.0-1.0)
|
||||
|
||||
@@ -74,8 +74,8 @@ class Enemic {
|
||||
AnimacioEnemic animacio_;
|
||||
|
||||
// [NEW] Behavior state (type-specific)
|
||||
float tracking_timer_; // For Quadrat: time since last angle update
|
||||
const Punt* ship_position_; // Pointer to ship position (for tracking)
|
||||
float tracking_timer_; // For Quadrat: time since last angle update
|
||||
const Punt* ship_position_; // Pointer to ship position (for tracking)
|
||||
|
||||
// [EXISTING] Private methods
|
||||
void mou(float delta_time);
|
||||
|
||||
@@ -39,8 +39,8 @@ class Nau {
|
||||
|
||||
// [NUEVO] Estat de la instància (separat de la geometria)
|
||||
Punt centre_;
|
||||
float angle_; // Angle d'orientació
|
||||
float velocitat_; // Velocitat (px/s)
|
||||
float angle_; // Angle d'orientació
|
||||
float velocitat_; // Velocitat (px/s)
|
||||
bool esta_tocada_;
|
||||
float brightness_; // Factor de brillantor (0.0-1.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user