diff options
author | elioat <elioat@tilde.institute> | 2024-12-27 08:19:00 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-27 08:19:00 -0500 |
commit | 73ae9acf92c4561868118a3fa38724c891ba0a8e (patch) | |
tree | 46b7d5caa2f42e3eb029ff8c9a573db05e1218ec /html/rogue/js/game.js | |
parent | 3a4c1117bfc0b902fdec41467bc6528d2f7a6f6d (diff) | |
download | tour-73ae9acf92c4561868118a3fa38724c891ba0a8e.tar.gz |
*
Diffstat (limited to 'html/rogue/js/game.js')
-rw-r--r-- | html/rogue/js/game.js | 11 |
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); } |