Class: Game
Defined in: utilities/game.ts:10
Manages the game loop: a Time instance and one or more EcsWorlds,
driven by requestAnimationFrame. Game is a simple loop orchestrator -
it has no notion of rendering, resizing, or anything else beyond updating
its worlds once per frame and stopping them when told to.
Implements
Constructors
Constructor
new Game(
time,worlds,container):Game
Defined in: utilities/game.ts:29
Creates a new Game instance.
Parameters
time
The Time instance for managing time-related operations.
worlds
readonly EcsWorld[]
The ECS worlds to update once per frame and stop when the game stops. A game can drive more than one, e.g. a gameplay world alongside a separate UI overlay world.
container
HTMLElement
The HTML element associated with the game.
Returns
Game
Properties
container
readonlycontainer:HTMLElement
Defined in: utilities/game.ts:16
The HTML element associated with the game (e.g. the one containing its
canvas), for consumers that need a DOM anchor (input sources, overlay
elements, etc.). Game itself does nothing with it.
Methods
run()
run():
void
Defined in: utilities/game.ts:38
Starts the game loop.
Returns
void
stop()
stop():
void
Defined in: utilities/game.ts:60
Stops the game loop.
Returns
void