All examples · Scenes · As Markdown, for AIs

Game systems

What this example shows

Press space to go to the other level, and R to wipe the progress.

Some code belongs to the whole game rather than to a scene. registerGameSystem(name, fn), called once before createGame, runs fn when the game starts, before its first scene, in a box no change of scene touches, and goes on until the game ends. Its useUpdate runs every frame before the scenes'. Here there are three, in systems/:

  • clock: counts the time played, whatever level is on. A paused game pauses it too.
  • achievements: watches the store and unlocks a title after ten seconds played, or after three visits to a level.
  • reset key: R wipes the progress from any level, without either level knowing.

They draw nothing: the levels show what they keep, from a store. Change the scene the game starts on in index.ts to 'Cave' and the three systems run just the same; a scene that launched them would be missing then, as it is when the editor plays one level straight away.

Starting
Starting
—