programgames/racer/play.xtl
The racer: three laps against three rivals. Up (or w) speeds you up, down (or s) slows you, left and right (or a and d) steer; keep off the grass, which slows you; r starts again. The race moves with the clock: on the page it is in a dialog, and the clock's ticks (twenty a second) and your keys come to the program as events; at the command line, lines such as "tick 0.05" and "key UP" on standard input. When you finish the program ends with your place (on the page, Play or any key then starts a new race). The rules are Race.xtl's, built on lib/Ecs.
ᵘs̲how : (Num a, Num b, Truthy b) => (Float, Float, a, b) -> Char
Show the game, then wait for the next event.
ᵘs̲how ← { s → _ ← ⎕S̲HOW ʳᶜd̲raw s 0 < ʳᶜs̲tatus s ? ᵘe̲nd s ᵘl̲oop s }
Used in: ᵘl̲oop, games/racer/play.xtl:35
ᵘl̲oop : (Num a, Num b, Truthy b) => (Float, Float, a, b) -> Char
The next event: a tick moves the game on and shows it; a key acts.
ᵘl̲oop ← { s → e ← ⎕E̲VENT @ "end" m̲atch ⎕E̲KIND e ? "THE END" "tick" m̲atch ⎕E̲KIND e ? ᵘs̲how s ʳᶜt̲ick f̲irst ⎕E̲AT e n̲ot "key" m̲atch ⎕E̲KIND e ? ᵘl̲oop s name ← f̲ormat ⎕E̲KEY e "r" m̲atch name ? ᵘs̲how ʳᶜn̲ew 0 ᵘl̲oop s ʳᶜk̲ey name }