about summary refs log tree commit diff stats
path: root/html/rogue/js/fow.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/rogue/js/fow.js')
-rw-r--r--html/rogue/js/fow.js51
1 files changed, 27 insertions, 24 deletions
diff --git a/html/rogue/js/fow.js b/html/rogue/js/fow.js
index 77f55c0..69a5d61 100644
--- a/html/rogue/js/fow.js
+++ b/html/rogue/js/fow.js
@@ -55,32 +55,35 @@ const FogOfWar = {
     
     // Draw fog of war effect
     draw(ctx) {
-        // Draw fog over unrevealed areas
         HexGrid.getViewportHexes().forEach(hex => {
-            if (!this.isRevealed(hex) || !this.isVisible(hex)) {
-                const pixel = HexGrid.toPixel(hex);
-                const screenX = pixel.x - Camera.x;
-                const screenY = pixel.y - Camera.y;
-                
-                ctx.fillStyle = this.isRevealed(hex) ? 
-                    'rgba(0, 0, 0, 0.5)' :  // Darker fog for unexplored areas
-                    'rgba(0, 0, 0, 0.8)';   // Lighter fog for explored but not visible
-                
-                // Draw fog hex
-                ctx.beginPath();
-                for (let i = 0; i < 6; i++) {
-                    const angle = 2 * Math.PI / 6 * i;
-                    const xPos = screenX + HexGrid.SIZE * Math.cos(angle);
-                    const yPos = screenY + HexGrid.SIZE * Math.sin(angle);
-                    if (i === 0) {
-                        ctx.moveTo(xPos, yPos);
-                    } else {
-                        ctx.lineTo(xPos, yPos);
-                    }
-                }
-                ctx.closePath();
-                ctx.fill();
+            const pixel = HexGrid.toPixel(hex);
+            const screenX = Math.round(pixel.x - Camera.x);
+            const screenY = Math.round(pixel.y - Camera.y);
+            
+            if (!this.isRevealed(hex)) {
+                ctx.fillStyle = 'rgba(0, 0, 0, 1)';
+                this.drawHexShape(ctx, screenX, screenY);
+            } else if (!this.isVisible(hex)) {
+                ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
+                this.drawHexShape(ctx, screenX, screenY);
             }
         });
+    },
+    
+    // Helper method to draw hex shape
+    drawHexShape(ctx, x, y) {
+        ctx.beginPath();
+        for (let i = 0; i < 6; i++) {
+            const angle = 2 * Math.PI / 6 * i;
+            const xPos = Math.round(x + HexGrid.SIZE * Math.cos(angle));
+            const yPos = Math.round(y + HexGrid.SIZE * Math.sin(angle));
+            if (i === 0) {
+                ctx.moveTo(xPos, yPos);
+            } else {
+                ctx.lineTo(xPos, yPos);
+            }
+        }
+        ctx.closePath();
+        ctx.fill();
     }
 }; 
\ No newline at end of file