Skip to content

Commit

Permalink
maze: Plan out keyboard input
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jun 30, 2024
1 parent 4feb357 commit 3f0712f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions maze.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,19 @@ function solve() {
if (repeat) setTimeout(solve, 1000);
}
window.solve = solve;

document.onkeydown = e => {
if (interval) return;
let dr = 0, dc = 0;
switch (e.code) {
case "ArrowUp": dr = -1; break;
case "ArrowDown": dr = 1; break;
case "ArrowLeft": dc = -1; break;
case "ArrowRight": dc = 1; break;
default: return;
}
//If there's a wall that way, do nothing. Should we show error?
//Flash the wall red maybe?
//TODO: Track the path-end location. Should we thus block mouse clicks that
//are adjacent to the middle of the path? Currently the path just branches.
};

0 comments on commit 3f0712f

Please sign in to comment.