Replays
A game played in the page is recorded as a replay of its commands: where it started and what its players did, a few hundred kilobytes for a melee. The replay scene plays it back with a bar to pause, speed up, step and seek.
Quick start
const scenes = [gameScene({ id: 'play', game }), replaysScene(), replayScene()]Games played on play are kept (GameScene.replays, on by default). The replays scene lists them; the replay scene plays one. See also How do I watch a replay and save one.
Common tasks
Don't record a scene
gameScene({ id: 'tutorial', game, replays: false })Change how often it checkpoints
gameScene({ id: 'play', game, replays: { checkpoints: 900 } }) // every 900 ticks; 0 for noneOpen a replay halfway
context.goTo(sceneRef('replay'), { id, at: 120 }) // seconds in
playReplay(replay, { at: 120 })
runReplay(replay, { from: 120 })Draw your own replay list or bar
replaysScene({ component: MyReplays }) // given a ReplaysController
replayScene({ bar: { component: MyBar } }) // given a ReplayPlaybackReference
Playback (ReplayPlayback, ReplayBar)
Hold, faster, slower, a tick at a time while held (step), and any moment by the slider. Seeking is in place, in the same game: the world runs to the moment a slice a frame (REPLAY_SLICE, 12 ms; ReplayPlayer.behind is what is left) and the bar shows progress while more than half a second is left (catchingUp). Going back starts from the last checkpoint before the moment (RemoteSession.resume).
Checkpoints
A game played in the page keeps the world every 1800 ticks (REPLAY_CHECKPOINTS, a minute at 30 ticks a second; RecordOptions.checkpoints, CommandReplay.checkpoints). Each is a whole save (about a megabyte for a full melee).
When a replay comes apart
The world's hash is recorded every ten seconds. Where the replay comes apart from what was recorded (the rules changed since), the bar says when (ReplayPlayback.apart), and from then on it is the game today's rules make.
recordGame records a game you put together yourself. The controllers are in The interface.