Fix projectiles and attacks passing through closed doors
Closed doors now block line of sight for both enemy AI and player weapons. Previously, door tiles were excluded from collision checks, allowing attacks through them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -229,7 +229,7 @@ class Enemy {
|
|||||||
const checkY = Math.floor(this.y + stepY * i);
|
const checkY = Math.floor(this.y + stepY * i);
|
||||||
if (checkY >= 0 && checkY < map.length && checkX >= 0 && checkX < map[0].length) {
|
if (checkY >= 0 && checkY < map.length && checkX >= 0 && checkX < map[0].length) {
|
||||||
const cell = map[checkY][checkX];
|
const cell = map[checkY][checkX];
|
||||||
if (cell > 0 && cell !== WALL_DOOR) return false;
|
if (cell > 0) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+1
-1
@@ -160,7 +160,7 @@ class WeaponSystem {
|
|||||||
const checkX = Math.floor(player.x + stepX * i);
|
const checkX = Math.floor(player.x + stepX * i);
|
||||||
const checkY = Math.floor(player.y + stepY * i);
|
const checkY = Math.floor(player.y + stepY * i);
|
||||||
if (checkY >= 0 && checkY < map.length && checkX >= 0 && checkX < map[0].length) {
|
if (checkY >= 0 && checkY < map.length && checkX >= 0 && checkX < map[0].length) {
|
||||||
if (map[checkY][checkX] > 0 && map[checkY][checkX] !== WALL_DOOR) {
|
if (map[checkY][checkX] > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user