Game is the main class that contains all the managers, scenes, entities and components. It allows to start and stop the execution of the game.

const game = new Game({
containerNode: document.getElementById("app"),
width: 1920,
height: 1080,
});
game.addScene(MainScene, "MainScene");
game.start();
const game = new Game({
containerNode: document.getElementById("app"),
width: 1920,
height: 1080,
debugEnabled: false,
canvasColor: "#000000",
physicsFramerate: 180,
collisions: {
collisionMatrix: [
["layer1", "layer2"],
["layer1", "layer3"],
],
collisionMethod: CollisionMethods.SAT,
collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
}
});
game.addScene(MainScene, "MainScene");
game.start();

Constructors

Accessors

  • get running(): boolean
  • TRUE if the game is running

    Returns boolean

Methods

  • Add a new instance to be used as dependency

    Parameters

    • dependencyInstance: any

      The dependency instance

    • name: DependencyName

      The name for the dependecy

    Returns void

  • Add a new class to be used as dependency

    Parameters

    • dependencyType: DependencyType

      The class of the dependency

    • Optionalname: DependencyName

      The name for the dependecy (optional: if the class uses the "injectable" decorator, this parameter is unnecesary)

    Returns void

  • Add a scene to the game

    Parameters

    • sceneType: SceneType

      The class of the scene

    • name: string

      The name for the scene

    • openingScene: boolean = false

      If this is the opening scene, set TRUE, FALSE instead (optional: default FALSE)

    Returns void

  • Start the game

    Returns void

  • Stop the game

    Returns void