Docs Design

Contents

Scenes joined by doors

The October audit's Wave 4 item "Scenes joined by doors" (docs/design/audit-2026-10.md). Before it, a game was played in one place: one generated world, everything in it at once. An adventure had no inside of a house, no cave, no cellar, and a quest could never go somewhere and come back to find things as they were.

Scenes (scenes in the GameManifest)

  • A scene is a place of its own: id, name, world (a WorldGen) and spawn (a place name of its world). The game starts in the first, whose world is the game's world. A scene with no world grows the game's WorldGen again from its own seed: a second wood like the first.
  • Worlds only, for now. Scenes are kit.world_tiles worlds; a platformer's levels already run in order and have no doors yet.
  • Each scene's world is made the first time the player goes in, from GwSeed.derive(root, "scene/<id>") (the first scene's from the root seed, so a game that adds scenes keeps its world), and kept from then on.

Doors and travel

  • A door is kit.core's door component on a usable (kit.harvest): the use key or a click on it takes the player through, to its to scene, at its at: a place name of that world, or an archetype or entity id (the player comes out in front of it, the way it faces, clear of both bodies, else at its side: the door back stands by the door the player came in by). Left out, the scene's spawn.
  • travel (kit.core's action) does the same from a rule, a state machine or a Timeline: a cutscene's end, a fall through the floor.
  • The move happens at the start of the next tick, first in kit.core's step, so every system steps the rest of that tick in the new place (GwScenes):
    1. every system hears GwSystem.scene_leaving;
    2. every entity but the player is put aside under the scene left, as saved rows, and those put aside under the scene entered come back as they were left (dead ones dead);
    3. every system hears GwSystem.scene_entered: kit.world_tiles takes up the scene's world, kit.brain_fsm drops its machines (the entities are new objects, as after a load);
    4. the player is set down at the spot asked for, and every system hears staged_at;
    5. scene.left and scene.entered go out (first the first time), and the latch scene:<id> is set.
  • What lives in a scene is spawned by a rule on scene.entered where event.first, as the first scene's cast is spawned on game.start.
  • Everything stays as it was left: the entities put aside, and the props worked down in every scene's world. A Timeline whose self is in another scene takes no step until the player comes back (a wait's time still runs).
  • Functions: scene() (the scene the player is in, "" in a game with none) and visited(id), so a HUD, a line or a Style's bed can tell where the player is.

State

  • kit.core keeps the scene, the scenes visited, the entities put aside and a move asked for, in its own state, and only in a game with scenes.
  • kit.world_tiles keeps the worked props of the world the player is in under props, as before, and every other scene's under away, by scene id; its stamp covers every scene's WorldGen.
  • A game with no scenes saves and hashes exactly as before.

Views

The world view watches its system's world: when a scene changes it, the next frame drops every chunk and builds the new world's round the player at once. The kits hold one world query, pointed at the scene's world (GwTileWorldQuery.rebind), so routes, places and props follow without them knowing.

Checks (core/src/game/scenes.ts)

Scene ids are unique (error); scenes need kit.world_tiles (error); the first scene's world is the game's (error); every door's to and every travel's scene names a scene, and a door or a travel in a game with no scenes is refused (errors); something leads into every scene after the first, and something leads back to the first (warnings).

In the samples

Thornwick: a burrow in Briar Wood's hollow leads down to Thorn Hollow, a clearing walled by pines where the third thornback nests (spawned the first time the hero goes down) among berry bushes. The way out comes up beside the burrow. Its hollow tour goes down, picks berries, saves and loads down there, and comes back up.

Not yet

  • Scenes in a platformer (side levels behind a door) and in a grid game.
  • A fade between scenes, and a camera that eases in: the camera cuts.
  • A scene's own light and music by itself (a Style's bed can already play when: scene() == ...).

From docs/design/scenes.md in the Gamewright repository.