diff --git a/html/XCOM/game.js b/html/XCOM/game.js
index 67846c5..cb542c8 100644
--- a/html/XCOM/game.js
+++ b/html/XCOM/game.js
@@ -69,7 +69,7 @@
const TILE_SIZE = 40;
const UNIT_RADIUS = 15;
const OBSTACLE_MAX_HEALTH = 20;
-const MAX_VISIBILITY_RANGE = 6; // Maximum distance units can see
+const MAX_VISIBILITY_RANGE = 10; // Maximum distance units can see
const ENEMY_TURN_SPEED = 0.3; // Enemy turns are 3x faster than player turns
const ENEMY_ACTION_FEEDBACK_DURATION = 800; // How long to show enemy action feedback
const AI_BEHAVIORS = ['aggressive', 'patrol', 'stationary'];
@@ -2452,6 +2452,7 @@ function App() {
let model = init();
let lastTime = 0;
let animationId;
+ let frameCount = 0;
// Set canvas dimensions based on model
canvas.width = model.grid[0].length * TILE_SIZE;
@@ -2495,6 +2496,7 @@ function App() {
function gameLoop(currentTime) {
const deltaTime = currentTime - lastTime;
lastTime = currentTime;
+ frameCount++;
// Update animations
model.units = updateAnimations(model.units, deltaTime);
@@ -2507,8 +2509,11 @@ function App() {
// Update obstacle flash effects
model.grid = updateObstacleFlash(model.grid);
- // Update unit visibility based on line of sight - ONLY when player units move or when needed
- // model.units = updateUnitVisibility(model.units, model.grid);
+ // Update unit visibility based on line of sight
+ // Update more frequently to ensure visibility changes are reflected
+ if (frameCount % 30 === 0 || model.units.some(u => u.isAnimating)) {
+ model.units = updateUnitVisibility(model.units, model.grid);
+ }
// Check if current unit has completed their turn and auto-advance
const currentTurnUnit = model.units.find(u => u.turnOrder === model.currentTurnIndex);
@@ -2713,7 +2718,6 @@ function checkLineOfSight(startX, startY, endX, endY, grid, units) {
const distance = Math.sqrt(dx * dx + dy * dy);
// Add maximum visibility range - units can't see beyond this distance
- const MAX_VISIBILITY_RANGE = 6; // Reduced from unlimited to 6 tiles
if (distance === 0) return { blocked: false, blocker: null, obstacleX: null, obstacleY: null };
|