blob: 047321c760b860bdccb589f5e5787a124bb8b987 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}
});
};
|