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.

ParamDescription
Vector2 GridGrid is visible scalable grid on canvas
object Page Settings{ backgroundColor: STRING }
float Canvas ScaleUsed for canvas scaling. Represents scale of parent element.

Constructing

Constructor for default game

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

Completing parameters

constGRID=newJSGL.Vector2(16,9);// this is not aspect ratio!constBACKGROUND_COLOR='black';constCANVAS_SCALE=1;constGAME_SETTINGS={grid: GRID};constPAGE_SETTINGS={backgroundColor: BACKGROUND_COLOR};constgame=JSGL.DefaultGame.Create(GAME_SETTINGS,PAGE_SETTINGS,CANVAS_SCALE);

Example short version

constgame=JSGL.DefaultGame.Create({grid: newJSGL.Vector2(10,10)},{backgroundColor: 'black'});

Clone this wiki locally