Skip to content

Creating game instance

Tymon Woźniak edited this page Apr 21, 2023 · 2 revisions

Creating Game instance

To create Game instance firstly you need to create grid, Page Settings, Canvas Scale.

Param Description
Vector2 Grid Grid is visible scalable grid on canvas
object Page Settings { backgroundColor: STRING }
float Canvas Scale Used for canvas scaling. Represents scale of parent element.

Constructing

Constructor for default game

JSGL.DefaultGame.Create(GAME_SETTINGS, PAGE_SETTINGS, CANVAS_SCALE);

Completing parameters

const GRID = new JSGL.Vector2(16, 9); // this is not aspect ratio!
const BACKGROUND_COLOR = 'black';
const CANVAS_SCALE = 1;

const GAME_SETTINGS = { grid: GRID };
const PAGE_SETTINGS = { backgroundColor: BACKGROUND_COLOR };

const game = JSGL.DefaultGame.Create(GAME_SETTINGS, PAGE_SETTINGS, CANVAS_SCALE);

Example short version

const game = JSGL.DefaultGame.Create({ grid: new JSGL.Vector2(10, 10)}, { backgroundColor: 'black' });
Clone this wiki locally