diff options
Diffstat (limited to 'html/rogue/js/game.js')
-rw-r--r-- | html/rogue/js/game.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/html/rogue/js/game.js b/html/rogue/js/game.js index f26e59b..427fab2 100644 --- a/html/rogue/js/game.js +++ b/html/rogue/js/game.js @@ -12,6 +12,7 @@ function init() { state.ctx = state.canvas.getContext('2d'); player.init(); + Debug.init(); function resize() { state.canvas.width = window.innerWidth; @@ -56,16 +57,18 @@ function drawHex(ctx, x, y, hex) { } function gameLoop(currentTime) { - requestAnimationFrame(gameLoop); // Request next frame first + requestAnimationFrame(gameLoop); if (currentTime - lastFrameTime < Config.game.FRAME_TIME) { - return; // Skip frame if too soon + return; } - // Ensure consistent time step const deltaTime = Math.min(currentTime - lastFrameTime, Config.game.FRAME_TIME * 2); lastFrameTime = currentTime; + // Update debug information + Debug.update(currentTime); + // Clear with background state.ctx.fillStyle = Config.colors.BACKGROUND; state.ctx.fillRect(0, 0, state.canvas.width, state.canvas.height); @@ -92,6 +95,7 @@ function gameLoop(currentTime) { player.draw(state.ctx, HexGrid.toPixel.bind(HexGrid), Camera, HexGrid.SIZE); FogOfWar.draw(state.ctx); InventoryUI.draw(state.ctx); + Debug.draw(state.ctx); } function handleClick(event) { |