Skip to main content

Class: Game

Defined in: ecs/game.ts:10

A game that manages worlds and handles the game loop.

Implements

Constructors

Constructor

new Game(container?): Game

Defined in: ecs/game.ts:31

Creates a new Game instance.

Parameters

container?

The HTML element that will contain the game.

string | HTMLElement

Returns

Game

Properties

container

readonly container: HTMLElement

Defined in: ecs/game.ts:20

The container element for the game. This is where the game will render its worlds.


onWindowResize

readonly onWindowResize: ForgeEvent

Defined in: ecs/game.ts:14

Event triggered when the window is resized.

Methods

deregisterWorld()

deregisterWorld(world): void

Defined in: ecs/game.ts:66

Deregisters a world from the game.

Parameters

world

World

The world to deregister.

Returns

void


registerWorld()

registerWorld(world): void

Defined in: ecs/game.ts:58

Registers a world to the game.

Parameters

world

World

The world to register.

Returns

void


run()

run(time): void

Defined in: ecs/game.ts:46

Starts the game loop.

Parameters

time

number = 0

The initial time value.

Returns

void


stop()

stop(): void

Defined in: ecs/game.ts:87

Stops the game and all registered worlds.

Returns

void

Implementation of

Stoppable.stop


swapToWorld()

swapToWorld(world): void

Defined in: ecs/game.ts:76

Swaps the current world with a new one. This deregisters all existing worlds and registers the new world.

Parameters

world

World

The new world to switch to.

Returns

void