Namespace graphics

A wrapper around graphics rendering and game loops. The graphics namespace provides the interface to the underlying renderer implementation. At the moment there are two renderers, one for using pure Canvas and one for using WebGL.

To use the graphics library create a Game implementation.

class MyGame implements Game {
image: GameImage;
tileSet: TileSet;

// load everything you want to use here
constructor() {
graphics.init(RendererType.WEBGL);
image = graphics.loadImage("https://game.com/image.png");
tileSet = graphics.loadTileSet("https://game.com/tiles.png", 32, 32);
}

// render everything in the game here
render(): void {
graphics.drawImage(image, 100, 100);
graphics.drawTile(tileSet, 200, 200, 0);
}

// notification that resources that were requested have been loaded
resourcesLoaded(): void {};

// input event call backs - use to control the game
mouseDown(): void {}
mouseUp(): void {}
mouseDragged(): void {}
keyUp(): void {}
keyDown(): void {}
}

Index

Enumerations

Interfaces

Type Aliases

Functions

Generated using TypeDoc