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:
co-authored by
Claude Opus 5.5
parent
e27372f017
commit
55f8b0b30f
@@ -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
|
||||
Reference in New Issue
Block a user