about summary refs log tree commit diff stats
path: root/html/rogue/js/input.js
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-12-24 15:53:19 -0500
committerelioat <elioat@tilde.institute>2024-12-24 15:53:19 -0500
commit8d4ebce0ef9eb7495e2b27a9a4df5f6001f7e65f (patch)
treed5a394ab15985715a70c1fb4ed8c4c09dcb65da4 /html/rogue/js/input.js
parentbb977cc4e502e3d35f3c82e1fca1a3535fda5e19 (diff)
downloadtour-8d4ebce0ef9eb7495e2b27a9a4df5f6001f7e65f.tar.gz
*
Diffstat (limited to 'html/rogue/js/input.js')
-rw-r--r--html/rogue/js/input.js19
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