enemics ja no ixen del area de joc
This commit is contained in:
@@ -36,9 +36,11 @@ void Nau::inicialitzar() {
|
||||
// [NUEVO] Ja no cal configurar punts polars - la geometria es carrega del
|
||||
// fitxer Només inicialitzem l'estat de la instància
|
||||
|
||||
// Posició inicial al centre de la pantalla
|
||||
centre_.x = 320.0f;
|
||||
centre_.y = 240.0f;
|
||||
// Posició inicial al centre de l'àrea de joc
|
||||
float centre_x, centre_y;
|
||||
Constants::obtenir_centre_zona(centre_x, centre_y);
|
||||
centre_.x = centre_x; // 320
|
||||
centre_.y = centre_y; // 213 (not 240!)
|
||||
|
||||
// Estat inicial
|
||||
angle_ = 0.0f;
|
||||
@@ -121,16 +123,18 @@ void Nau::aplicar_fisica(float delta_time) {
|
||||
(velocitat_ * delta_time) * std::cos(angle_ - Constants::PI / 2.0f) +
|
||||
centre_.x;
|
||||
|
||||
// Boundary checking - només actualitzar si dins de la zona de joc
|
||||
// Acumulació directa amb precisió subpíxel
|
||||
// Boundary checking amb radi de la nau
|
||||
// CORRECCIÓ: Usar límits segurs i inequalitats inclusives
|
||||
float min_x, max_x, min_y, max_y;
|
||||
Constants::obtenir_limits_zona(min_x, max_x, min_y, max_y);
|
||||
Constants::obtenir_limits_zona_segurs(Defaults::Entities::SHIP_RADIUS,
|
||||
min_x, max_x, min_y, max_y);
|
||||
|
||||
if (dy > min_y && dy < max_y) {
|
||||
// Inequalitats inclusives (>= i <=)
|
||||
if (dy >= min_y && dy <= max_y) {
|
||||
centre_.y = dy;
|
||||
}
|
||||
|
||||
if (dx > min_x && dx < max_x) {
|
||||
if (dx >= min_x && dx <= max_x) {
|
||||
centre_.x = dx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user