gameplate - v2.3.0
    Preparing search index...

    Interface GameConfig<S, A>

    Configuration for createGame. See the property docs for a full tour; the only required fields are state and actions.

    interface GameConfig<S, A extends ActionMap<S>> {
        state: S;
        actions: A;
        update?: (state: DeepReadonly<S>, dt: number, actions: Dispatch<A>) => void;
        render?: (state: DeepReadonly<S>, alpha: number) => void;
        fixedStep?: number;
        fixedUpdate?: (
            state: DeepReadonly<S>,
            dt: number,
            actions: Dispatch<A>,
        ) => void;
        maxDelta?: number;
        keyboard?: boolean | { target?: EventTarget; preventDefault?: boolean };
        pointer?: boolean | { target?: EventTarget };
        gamepad?: boolean | GamepadOptions;
        dev?: boolean;
        scheduler?: Scheduler;
        seed?: string | number;
        timers?: boolean;
        tap?: ActionTap;
    }

    Type Parameters

    Index

    Properties

    state: S

    Initial state.

    actions: A

    Action map. Use defineActions for the best inference.

    update?: (state: DeepReadonly<S>, dt: number, actions: Dispatch<A>) => void

    Per-frame update hook. Receives current state, frame dt (seconds), and the dispatcher so you can call actions from here.

    render?: (state: DeepReadonly<S>, alpha: number) => void

    Per-frame render hook. Receives state and alpha (interpolation factor if fixedStep is set, else 0).

    fixedStep?: number

    Seconds per fixed tick (e.g. 1/60). Omit for a variable-step loop.

    fixedUpdate?: (state: DeepReadonly<S>, dt: number, actions: Dispatch<A>) => void

    Fixed-step physics hook. Use when fixedStep is set.

    maxDelta?: number

    Cap on dt per frame (seconds). Default 0.25.

    keyboard?: boolean | { target?: EventTarget; preventDefault?: boolean }

    Whether to instantiate a Keyboard. Defaults true in browsers.

    pointer?: boolean | { target?: EventTarget }

    Whether to instantiate a Pointer. Defaults true in browsers.

    gamepad?: boolean | GamepadOptions

    Whether to instantiate a Gamepad. Defaults true in browsers. When enabled, the gamepad is polled automatically at the start of every update tick — game.gamepad.isDown('A') inside your update hook reads fresh state from the platform.

    dev?: boolean

    When true, every state value is Object.freezed. Use in dev only.

    scheduler?: Scheduler

    Custom scheduler (tests, headless Node loop, etc.).

    seed?: string | number

    Seed for game.random, the built-in seeded RNG. Pass a value for reproducible runs; omit for an auto-seeded generator (read game.random.seed to recover it).

    timers?: boolean

    Whether to instantiate game.timers and auto-advance it at the top of every update tick. Default true. Set false to opt out of the per-tick advance (the pool is still created so game.timers is defined).

    tap?: ActionTap

    Fires synchronously after every dispatched action's setState succeeds, with the action name and its arguments. Hook a recorder, logger, or analytics sink here.

    Firing after setState (rather than before) is deliberate: it keeps the recorded event order identical to the apply order even when the tap itself dispatches further actions, and skips events for actions that threw — so recordings remain deterministically replayable.