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

mountKarakurifunction

Plays one game of the package in host: a canvas that scales to the box it is given, the pointer (finger or mouse) wired to the game, a fixed-step loop that runs only while something moves, and (with ui: "full") the bar, the buttons and the card that says how a level ended. Safe to call again on the same host: the old game is taken down first. The focused canvas accepts arrows, Enter/Space, Escape and Home when keyboard is enabled.

Import it

import { mountKarakuri } from "@johnmorrisdotca/karakuri/play";

Definition

function mountKarakuri(host: HTMLElement, options: MountOptions): KarakuriMount

Parameters

NameTypeDescription
hostHTMLElement

The element that owns this player's canvas and controls.

optionsMountOptions

Native game/controller, presentation, clock and lifecycle choices.

Returns

KarakuriMount

A handle for reading the controller, changing levels/language, stepping, fitting and cleanup.

Examples

import { mountKarakuri } from "@johnmorrisdotca/karakuri/play";
if (typeof document !== "undefined") {
  const player = mountKarakuri(document.createElement("div"), { game: "tube-sort", clock: "manual" });
  player.destroy();
}
console.log(typeof mountKarakuri);
function

What it prints (run when this page was built)

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