about summary refs log tree commit diff stats
path: root/html/side-scrolling-rogue-thing/js/input.js
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-12-27 07:25:05 -0500
committerelioat <elioat@tilde.institute>2024-12-27 07:25:05 -0500
commit1ae1729728f0907ddb17e9303edad19aa2ff143c (patch)
treeb7bb5082e9099890156d9e9c36866a9dc2b8ee99 /html/side-scrolling-rogue-thing/js/input.js
parentf1268ab00394de6f751c58f825efbc905680b161 (diff)
downloadtour-1ae1729728f0907ddb17e9303edad19aa2ff143c.tar.gz
*
Diffstat (limited to 'html/side-scrolling-rogue-thing/js/input.js')
-rw-r--r--html/side-scrolling-rogue-thing/js/input.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/html/side-scrolling-rogue-thing/js/input.js b/html/side-scrolling-rogue-thing/js/input.js
new file mode 100644
index 0000000..047321c
--- /dev/null
+++ b/html/side-scrolling-rogue-thing/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
8f61d5c8b5a76bc3f7a5962cb7490da3b6b'>7b5638f ^
f22d047 ^
39d1ecd ^



d7e1708 ^
71fd06f ^


71fd06f ^
95766d6 ^
1076f2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33