Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

Reference · Controllers and canvas player

KarakuriMounttype

The native handle, including its controller and focused keyboard canvas.

Import it

import type { KarakuriMount } from "@johnmorrisdotca/karakuri/play";

Definition

interface KarakuriMount {
    readonly game: KarakuriGame;
    readonly level: number;
    readonly status: Status;
    readonly controller: Controller;
    readonly canvas: HTMLCanvasElement;
    restart(): void;
    setLevel(level: number): void;
    setLang(lang: KarakuriLanguage): void;
    advance(ticks: number): void;
    toClient(x: number, y: number): {
        x: number;
        y: number;
    };
    redraw(): void;
    destroy(): void;
}

Members

NameTypeDescription
game"save-the-character" | "pin-rescue" | "nuts-and-bolts" | "stretch-grabber" | "grid-escape" | "rope-cut" | "tube-sort" | "choice-story"
levelnumber
statusStatus
controllerController

The controller of the level being played, for reading its snapshot.

canvasHTMLCanvasElement
restart(): void
setLevel(level: number): void

Goes to another level (from 1) of the same game; a number out of range is held to the nearest.

setLang(lang: KarakuriLanguage): void
advance(ticks: number): void

Steps ticks fixed steps now and draws. With clock: "manual" this is the only thing that moves time.

toClient(x: number, y: number): { x: number; y: number; }

Where a place in the game's own units is on the page, in client pixels (for a test or a guide to point at).

redraw(): void

Fits the board to its box again (asking room again) and draws it now: after a change of theme, or of the room the page keeps round the board.

destroy(): void

Examples

import type { KarakuriMount } from "@johnmorrisdotca/karakuri/play";
const restart = (player: KarakuriMount): void => { player.restart(); player.redraw(); };
console.log(typeof restart);
function

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.