Gleam - v1.0.2
    Preparing search index...

    Class GameAbstract

    Abstract base for a Gleam game. Subclass it and implement init, update, and draw. The constructor wires up CanvasManager, Gameloop, Keyboard, and Pointer; the subclass must register at least one canvas with canman.setupCanvas(...) and then call preInit to start everything.

    Singleton-per-page. The framework registers global listeners on window/document and writes history.scrollRestoration; multiple instances on the same page will fight each other.

    Index

    Constructors

    Properties

    canman: CanvasManager = ...

    Canvas registry + 2D context exposure. Register canvases here from the constructor (canman.setupCanvas(CANVAS_TYPES.MAIN, "#game")) before calling preInit.

    gameloop: Gameloop

    The fixed-step driver. Started automatically by preInit when Settings.autoloop is true.

    keyboard: Keyboard

    Live keyboard state. See Keyboard.

    pointer: Pointer

    Live pointer (mouse / pen / touch) state. See Pointer.

    Methods

    • Render the current frame. Called by Gameloop after the canvas is cleared. Subclasses must override — the default throws.

      Parameters

      • _context: CanvasRenderingContext2D

      Returns void

    • One-time setup hook (assets, world build) invoked by preInit. Can be async; the loop waits for it to resolve before starting. Do not call directly — kick off via preInit from the constructor. Subclasses must override — the default throws.

      Returns Promise<void>

    • Finalise engine wiring and start the loop. Call once from the subclass constructor after registering canvases. Steps: canman.finishSetup() → install debounced window.resize → reset gameloop.levelTimeawait this.init() (if doInit) → dispatch "resized" → start the loop if Settings.autoloop. Throws if called twice. Pass doInit: false to skip the init() await (useful for tests).

      Parameters

      • doInit: boolean = true

      Returns Promise<void>

    • Advance the simulation by dt seconds (= Settings.fps). Called by Gameloop zero-or-more times per frame depending on real-time accumulation. Subclasses must override — the default throws.

      Parameters

      • _dt: number

      Returns void