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

MountOptionstype

Initial native controller, level, layout, keyboard, clock and host callbacks.

Import it

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

Definition

interface MountOptions {
    game: KarakuriGame;
    controller?: Controller;
    keyboard?: boolean;
    keyboardStep?: number;
    level?: number;
    lang?: KarakuriLanguage;
    ui?: "full" | "board";
    room?: () => number;
    clock?: "real" | "manual";
    onStatus?: (event: StatusEvent) => void;
    onChange?: (event: StatusEvent) => void;
}

Members

NameTypeDescription
game"save-the-character" | "pin-rescue" | "nuts-and-bolts" | "stretch-grabber" | "grid-escape" | "rope-cut" | "tube-sort" | "choice-story"
controller (optional)Controller | undefined

A matching host-owned controller, for preserving an existing position.

keyboard (optional)boolean | undefined

Allow a focused canvas to use the keyboard. Default true.

keyboardStep (optional)number | undefined

Arrow movement in game units; Shift always moves one unit. Default 10.

level (optional)number | undefined

The level to start on, from 1.

lang (optional)KarakuriLanguage | undefined

en or ja; the page's own language when left out.

ui (optional)"full" | "board" | undefined

full (default) draws the bar above the board, the result card on it and the buttons below; board draws the board alone, for a page that has its own buttons.

room (optional)(() => number) | undefined

The most height, in pixels, the board may take now. A page that puts something above or under the board says how much room is left (it is asked again whenever the board is fitted: on a resize, and when the box it sits in changes size). By default most of the window: 82% of its height, less 120 pixels for the bar and buttons when ui is full.

clock (optional)"real" | "manual" | undefined

real (default) steps with the display; manual steps only when advance is called, for a test that must see exact frames.

onStatus (optional)((event: StatusEvent) => void) | undefined

Called whenever the level's status changes (and once at the start, as playing).

onChange (optional)((event: StatusEvent) => void) | undefined

Called after each move, release or step that changed what is shown (the bar's line included).

Examples

import type { MountOptions } from "@johnmorrisdotca/karakuri/play";
const options: MountOptions = { game: "tube-sort", clock: "manual", keyboard: true };
console.log(options.game);
tube-sort

What it prints (run when this page was built)

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