Making a game
Scene flow
More than one scene: titles, menus, levels, cutscenes and game over.
A game of more than one scene: a title, levels, a game over, and moving seats between them with the scenemanager.
How it is laid out
- The manager scene,
<game>.scene.json, names every scene in itsscenemanagerprefab:scenes(a name to{ file, suspend, enter? }) andentry, the scene every connection enters first. - A child scene's
prefabsandworldare the manager's with its own over them, key by key. - Scenes played on one place, a skirmish and its missions or a level by day and by night, share a partial,
<name>.partial_scene.json, which is never a scene of its own and is not inscenes. - A
suspend: truescene nobody is in does not step. A scene is booted once and keeps its rows when seats leave.
Steps
- Write the scene:
<scene>.scene.jsonand<scene>.sim.tsbeside the manager's, withscenemanagerin itsplugins, and an entry in the manager'sscenes. A second level hands out the sim of the scene it shares its kinds with,export { sim } from './main.sim.ts'; a title or a game-over screen has a sim of its own. - For scenes on one place, put the ground, the
worldand the actors every one of them places alike in the partial, and have each scene name it as"extends"and hold only what makes it different. A row two scenes place differently, such as each scene'sstartwith its own loadout, is an actor of each scene. A new variation is a new scene file naming the partial. - Name the scene's own kind after no scene: a
titlescene shows atitlecard. - Move
world.defsandworld.loaderinto the manager'sworld, so every scene inherits them. - Set
entryin the manager's prefab. - Make a title or game-over screen a scene with
"plugins": ["loader", "scenemanager", "ui"]and noplayer. Its button sends the seat on withplugins.scenemanager.go(name, ...args). - Move a seat from a rule with
w.call(w.find('scenemanager'), 'go', seat, name, ...args).seatis the seat number an act was handed, not the slot. - Carry a score or lives as
go's args. They arrive on the next scene'splayerrow as the actarrive, which checks each value's type and range. - Keep every scene name in a definition or the level's
world, never in code. - Rewrite
<game>.sim.test.tsto start from the new entry.
"prefabs": {
"scenemanager": {
"entry": "title",
"scenes": {
"title": { "file": "title.scene.json", "suspend": true },
"main": { "file": "main.scene.json", "suspend": true }
}
}
}
Starting a level over
A level a seat returns to is as it was left. Name an enter: { kind, act } in its scenes entry; the act runs for each seat that enters and can spawn the cast again from w.world.scenemanager.actors.
What crosses a move
| Crosses | Does not cross |
|---|---|
| The page's store: volume, rebound keys. | The seat's player row and its fields. |
go's args, as arrive, into a scene that lists player. | The page's actors, plugins, keys and open panels. |
| The scene left behind, with its rows. | Anything past the process; that is persist. |
A cutscene
A cutscene with go in its cue file sends the kinds world.cutscene.kinds names on at its end. It plays once per scene.
Checking it
- In
<game>.sim.test.ts, connect a seat, check it enters the entry, sendgo, and read the next scene's rows. - A test that reads a scene file to know what to expect loads it with the scenemanager's
child, never by importing<scene>.scene.json, which holds only the scene's own part when it extends a partial. - Enter a scene directly from
dev.htmlwithfile.prefabs.scenemanager.entry = '<scene>'. - Open the game's
index.htmlas in Starting a game, and play from the entry through each scene, and back.