diff options
Diffstat (limited to 'html/rogue/js/input.js')
-rw-r--r-- | html/rogue/js/input.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/html/rogue/js/input.js b/html/rogue/js/input.js new file mode 100644 index 0000000..047321c --- /dev/null +++ b/html/rogue/js/input.js @@ -0,0 +1,19 @@ +const setupInputHandlers = (canvas, gameState) => { + let mouseMoveThrottle; + + canvas.addEventListener('mousemove', (e) => { + if (!mouseMoveThrottle) { + mouseMoveThrottle = setTimeout(() => { + gameState.debug.mouseX = e.clientX + gameState.camera.x; + gameState.debug.mouseY = e.clientY + gameState.camera.y; + mouseMoveThrottle = null; + }, 16); + } + }); + + window.addEventListener('keydown', (e) => { + if (e.key === 'd') { + gameState.debug.enabled = !gameState.debug.enabled; + } + }); +}; \ No newline at end of file |