Interface GameConfig

Game configuration options

const gameConfig = {
containerNode: document.getElementById("app"),
width: 1920,
height: 1080,
debugEnabled: false,
canvasColor: "#000000",
physicsFramerate: 180,
headless: false,
dependencies: [[Symbol.for("DependencyName"), dependencyInstance]],
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;
    debug?: {
        colliders: boolean;
        collidersColor?: string;
        mousePosition: boolean;
        textColor?: string;
        textPosition?:
            | "top-left"
            | "top-right"
            | "bottom-left"
            | "bottom-right";
    };
    dependencies?: [DependencyName, any][];
    headless?: boolean;
    height: number;
    physicsFramerate?: number;
    width: number;
}

Properties

canvasColor?: string

Background color of canvas, default "#000000" (black)

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

debug?: {
    colliders: boolean;
    collidersColor?: string;
    mousePosition: boolean;
    textColor?: string;
    textPosition?:
        | "top-left"
        | "top-right"
        | "bottom-left"
        | "bottom-right";
}

Debug options

Type declaration

  • colliders: boolean

    Show colliders

  • OptionalcollidersColor?: string

    Color of the colliders, default "#00FF00" (green)

  • mousePosition: boolean

    Show mouse position

  • OptionaltextColor?: string

    Color of the text, default "#00FF00" (green)

  • OptionaltextPosition?:
        | "top-left"
        | "top-right"
        | "bottom-left"
        | "bottom-right"

    Position of debug text, default "bottom-left"

dependencies?: [DependencyName, any][]

External elements which can be accessed through dependency injection.

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