afegides zones

This commit is contained in:
2025-11-29 09:04:18 +01:00
parent 832f77de80
commit 89302a2ee3
6 changed files with 55 additions and 21 deletions

View File

@@ -85,10 +85,14 @@ void Enemic::mou(float delta_time) {
float new_y = centre_.y + dy;
float new_x = centre_.x + dx;
// Obtenir límits de la zona de joc
float min_x, max_x, min_y, max_y;
Constants::obtenir_limits_zona(min_x, max_x, min_y, max_y);
// Lògica Pascal: Actualitza Y si dins, sinó ajusta angle aleatòriament
// if (dy>marge_dalt) and (dy<marge_baix) then orni.centre.y:=round(Dy)
// else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
if (new_y > Constants::MARGE_DALT && new_y < Constants::MARGE_BAIX) {
if (new_y > min_y && new_y < max_y) {
centre_.y = new_y;
} else {
// Pequeño ajuste aleatorio: (random(256)/512)*(random(3)-1)
@@ -103,7 +107,7 @@ void Enemic::mou(float delta_time) {
// Lògica Pascal: Actualitza X si dins, sinó ajusta angle aleatòriament
// if (dx>marge_esq) and (dx<marge_dret) then orni.centre.x:=round(Dx)
// else orni.angle:=orni.angle+(random(256)/512)*(random(3)-1);
if (new_x > Constants::MARGE_ESQ && new_x < Constants::MARGE_DRET) {
if (new_x > min_x && new_x < max_x) {
centre_.x = new_x;
} else {
float rand1 = (static_cast<float>(std::rand() % 256) / 512.0f);