feat(fsharp): m09 input/app/runtime and m10 extensions with tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-29 00:56:27 +01:00
co-authored by Claude Opus 5.5
parent e27372f017
commit 55f8b0b30f
14 changed files with 435 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
/// m09 input: from keyboard keys to game actions.
module Snake.Input
open Snake.Model
// A match on string literals is the lookup table; `|` lists the alternatives.
let keyToAction (key: string) : Action option =
match key with
| "ArrowUp" | "w" | "W" -> Some(Turn Up)
| "ArrowDown" | "s" | "S" -> Some(Turn Down)
| "ArrowLeft" | "a" | "A" -> Some(Turn Left)
| "ArrowRight" | "d" | "D" -> Some(Turn Right)
| " " -> Some TogglePause // m10
| "r" | "R" -> Some Restart // m10
| _ -> None