Overview
This section states how a build writes its code against Structured 2D: the shape of a build, the worked examples, and the idioms the engine expects. Every example here is game-side code.
The engine ships its own documentation inside its package. Seeding copies that
directory into the run workspace at engine/, and the rendered prompt names the
engine and points the build at it, so a model builds against the same contract
this section states.
The division
Section titled “The division”The build supplies a
GameDefinition: a game instance
class, a level registry, and the level the engine opens first. A level names the
game mode to run and the actors placed in it. The engine builds a world from
that description and drives it.
Opening a level awaits the level’s load, then constructs the game mode, the
game state, and the declared actors. Every declared actor’s beginPlay runs in
spawn order once all of them exist, and the game mode’s beginPlay runs last.
Each frame the engine ticks the controllers, then the actors and their
components, then the timers, then the collision pass, then the game mode, and
renders the result.
The game instance is the one framework object that outlives a level transition,
so a value that must survive travel lives there and a value scoped to one match
lives on the game state. The instance’s initialize is where the action
bindings, the cue definitions, the instance’s assets, and its diagnostic sources
are declared, and it returns the debug surface a caller drives the build through.
| Page | Covers |
|---|---|
| Creating the Engine | The design size, the options createEngine takes, sizing the canvas from CSS, choosing a clock, booting, and teardown. |
| Levels and Worlds | Registering levels, loading what a level needs, opening one from play, and what crosses a transition. |
| Game Modes | Writing a mode’s rules, moving the match through its phases, adding players and bots, and carrying figures on the game state. |
| Actors and Components | Writing an actor, attaching components, tagging, finding peers, and destroying. |
| Controllers and Pawns | Reading actions in a player controller, driving a pawn, and running the same pawn from an AI controller. |
| Rendering | Attaching render components, ordering them by layer, the render modes, and drawing directly. |
| Collision | Declaring colliders, channels and responses, applying a response from the engine’s events, and the queries. |
| Audio and Assets | Defining and loading cues, playing them from a tick, and loading assets under the asset root. |
| Diagnostics | Registering instance and world sources and choosing what a case’s checks can read. |
| Debug Surface | Declaring the surface type, writing its poses and readings as methods over the live world, returning it from initialize, and driving it through engine.debug. |