about summary refs log tree commit diff stats
path: root/html/rogue/js/game.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/rogue/js/game.js')
-rw-r--r--html/rogue/js/game.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/html/rogue/js/game.js b/html/rogue/js/game.js
index d5891d7..5ce9f1e 100644
--- a/html/rogue/js/game.js
+++ b/html/rogue/js/game.js
@@ -24,6 +24,7 @@ function init() {
     state.canvas.addEventListener('click', handleClick);
     
     requestAnimationFrame(gameLoop);
+    FogOfWar.init();
 }
 
 function drawHex(ctx, x, y, hex) {
@@ -82,6 +83,13 @@ function gameLoop(currentTime) {
     player.update();
     Camera.smoothFollow(player.getCurrentPosition());
     
+    // Update fog of war when player moves
+    if (player.hasMoved) {
+        FogOfWar.updateVisibility(player.position);
+        player.hasMoved = false;
+    }
+    
+    // Draw layers in correct order
     HexGrid.getViewportHexes().forEach(hex => {
         const pixel = HexGrid.toPixel(hex);
         drawHex(state.ctx, pixel.x, pixel.y, hex);
@@ -89,6 +97,9 @@ function gameLoop(currentTime) {
     
     player.draw(state.ctx, HexGrid.toPixel.bind(HexGrid), Camera, HexGrid.SIZE);
     
+    // Draw fog of war last
+    FogOfWar.draw(state.ctx);
+    
     requestAnimationFrame(gameLoop);
 }