blob: 047321c760b860bdccb589f5e5787a124bb8b987 (
plain) (
tree)
|
|
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;
}
});
};
|