Game

Handles numerous aspects of the game for you, such as the world, physics engine, rendering, ticking, and making bodies.

Constructor

new Game(options)

Default options:

{
	World: World.defaultOptions,
	Render: Render.defaultOptions,
	Engine: Engine.defaultOptions,
	Ticker: Ticker.defaultOptions,
}

See documentation for World, Render, Engine, and Ticker for options

Parameters:
NameTypeDescription
optionsObject

Options object

Properties
NameTypeAttributesDescription
WorldObject<optional>

World options

RenderObject<optional>

Render options

EngineObject<optional>

Engine options

TickerObject<optional>

Ticker options

Example
let game = new Game({
	World: {
		gravity: new vec(0, 0),
	},
	Render: {
		background: "#ffffff",
		ySort: false,
		antialias: true,
	},
	// Engine and Ticker omitted
});

Methods

createDebugRender()

Creates a debug rendering context as this.DebugRender. See DebugRender and the tutorial for more information.

Example
// creates game.DebugRender
game.createDebugRender(); 

// which we can now use here
game.DebugRender.enabled.wireframes = true;
game.Engine.Performance.render.enabled = true; // fps graph