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

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

40.0 kB minified and gzipped, with everything it imports (measured with esbuild)

Exports

NameKindWhat it is
ControllertypeOne level of one game, played.
createControllerfunctionMakes a controller for level level (from 1) of a game; a level out of range is held to the nearest.
defaultThemefunctionThe theme without a page: the light one, for a drawing made where there is no style to read (a test, a server).
GameInfotypeWhat a game of the package is, for a chooser.
InfotypeWhat the player reads in the bar above the board.
KARAKURI_GAME_IDSconstantThe ids of the games, in the order the package lists them (kebab case, the same in every address and attribute).
KARAKURI_GAMESconstantTHE GAMES of the package, by id.
KARAKURI_STYLEconstantTHE STYLE the player wears: the colours as custom properties on .karakuri (light, and dark when the page asks for it by prefers-color-scheme or by data-theme="dark" on the root), the layout of the bar, the play area and the buttons, and the one rule that matters for games played with fingers: nothing on the board can be selected, dragged or double-tapped, and the play area stops the page scrolling under a finger only for the games that read a finger's whole path.
KARAKURI_THEMESconstantThe look the games draw with, as custom properties, so a page can change any of them.
KarakuriGametypeThe id of a game of the package.
KarakuriMounttypeThe native handle, including its controller and focused keyboard canvas.
mountKarakurifunctionPlays 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.
MountOptionstypeInitial native controller, level, layout, keyboard, clock and host callbacks.
PointtypeA place in a game's own world, in its own units (not pixels).
readThemefunctionReads the theme a game draws with from an element's computed style: each colour is --kk-<name>, with the light or the dark default beneath.
SaytypeA line of words to be said in the player's language: a key of KARAKURI_STRINGS and the values for its {name}s.
StatustypeHow a level stands: still being played, won, or lost.
StatusEventtypeWhat a status callback is given.
ThemetypeThe colours and sizes a game draws with, read from the page's custom properties (--kk-*) so that it follows light, dark and the family's cloths.

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