Here's the full code:
This is the code that I'm interested in:
Code:
window.addEventListener("keydown", e => { inputDir = { x: 0, y: 1 }; moveSound.play(); switch (e.key) { case "ArrowUp": inputDir.x = 0; inputDir.y = -1; break; case "ArrowDown": inputDir.x = 0; inputDir.y = 1; break; case "ArrowLeft": inputDir.x = -1; inputDir.y = 0; break; case "ArrowRight": inputDir.x = 1; inputDir.y = 0; break; } })
What I'm not understanding is why are we setting inputDir at 0th row, 1st column? What does that mean? Can you provide some explanations with figures(if possible) about this issue?
Comment