Interface GameConfig

Game configuration options

const gameConfig = {
containerNode: document.getElementById("app"),
width: 1920,
height: 1080,
debugEnabled: false,
canvasColor: "#000000",
physicsFramerate: 180,
headless: false,
collisions: {
collisionMatrix: [
["layer1", "layer2"],
["layer1", "layer3"],
],
collisionMethod: CollisionMethods.SAT,
collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
}
};
interface GameConfig {
    canvasColor?: string;
    collisions?: {
        collisionBroadPhaseMethod?: BroadPhaseMethods;
        collisionMatrix?: CollisionMatrix;
        collisionMethod?: CollisionMethods;
    };
    containerNode: HTMLElement;
    debugEnabled?: boolean;
    headless?: boolean;
    height: number;
    physicsFramerate?: number;
    width: number;
}

Properties

canvasColor?: string

Background color of canvas

collisions?: {
    collisionBroadPhaseMethod?: BroadPhaseMethods;
    collisionMatrix?: CollisionMatrix;
    collisionMethod?: CollisionMethods;
}

Collision configuration options

Type declaration

  • OptionalcollisionBroadPhaseMethod?: BroadPhaseMethods

    Collision broad phase method: BroadPhaseMethods.QuadTree or BroadPhaseMethods.SpartialGrid. Default values is BroadPhaseMethods.SpartialGrid

  • OptionalcollisionMatrix?: CollisionMatrix

    Define a fixed rectangular area for collision detection

  • OptionalcollisionMethod?: CollisionMethods

    Collision detection method: CollisionMethods.SAT or CollisionMethods.ABB. Default value is CollisionMethods.SAT

containerNode: HTMLElement

HTML element where the game will be created

debugEnabled?: boolean

Enables the debug mode

headless?: boolean

Enable Headless mode. The input and rendering functions are turned off. Ideal for game server development

height: number

Game height

physicsFramerate?: number

Framerate for physics execution. The allowed values are 60, 120, 180, 240. The higher the framerate, the more accurate the physics will be, but it will consume more processor resources. Default value is 180.

width: number

Game width