feat(js): m10 extensions (pause, restart, speed-up via Frame) with tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-28 23:56:49 +01:00
co-authored by Claude Sonnet 5.5
parent 25141ce86d
commit fd7c5f2acf
13 changed files with 1347 additions and 17 deletions
+11 -1
View File
@@ -4,12 +4,21 @@ import { pure } from './io.js'
/** Milliseconds between game steps. */
export const TICK_MS = 150
/** Milliseconds between animation frames (m10). */
export const FRAME_MS = 25
/**
* Stream of everything that can happen to the game: `Action.Tick` every TICK_MS (from `interval`),
* merged with the `Action` for each key press that `keyToAction` recognises (from `keyDowns`).
*/
export const classicActions = { step: () => todo('m09') }
/**
* (m10) Like `classicActions`, but the clock emits `Action.Frame` every FRAME_MS instead of `Tick` every TICK_MS;
* key presses are translated by `keyToAction` as before (now including pause and restart).
*/
export const speedActions = { step: () => todo('m10') }
/**
* Fold a stream of actions into a stream of game states: start from `newGame(seed)`, apply `update` to each action
* (scan), and emit the initial state first (startWith) so there is something to draw before anything happens.
@@ -21,6 +30,7 @@ export const render = (state) => todo('m09')
/**
* The whole program as a value, `IO<Stream<IO<unit>>>`: ask for a random seed, then turn the stream of
* states (built from `classicActions`) into a stream of drawings (`render`). Nothing runs here.
* states (built from `classicActions` in m09, from `speedActions` after m10) into a stream of drawings (`render`).
* Nothing runs here.
*/
export const main = pure({ step: () => todo('m09') })