diff options
author | elioat <elioat@tilde.institute> | 2024-12-24 15:53:19 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-24 15:53:19 -0500 |
commit | 8d4ebce0ef9eb7495e2b27a9a4df5f6001f7e65f (patch) | |
tree | d5a394ab15985715a70c1fb4ed8c4c09dcb65da4 /html/rogue/js/input.js | |
parent | bb977cc4e502e3d35f3c82e1fca1a3535fda5e19 (diff) | |
download | tour-8d4ebce0ef9eb7495e2b27a9a4df5f6001f7e65f.tar.gz |
*
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 |