本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス

操作とキャンバスの表示

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

最小化と gzip 圧縮をしたサイズは 40.0 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

エクスポート

名前種類概要
Controller型One level of one game, played.
createController関数Makes a controller for level level (from 1) of a game; a level out of range is held to the nearest.
defaultTheme関数The theme without a page: the light one, for a drawing made where there is no style to read (a test, a server).
GameInfo型What a game of the package is, for a chooser.
Info型What the player reads in the bar above the board.
KARAKURI_GAME_IDS定数The ids of the games, in the order the package lists them (kebab case, the same in every address and attribute).
KARAKURI_GAMES定数THE GAMES of the package, by id.
KARAKURI_STYLE定数THE 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_THEMES定数The look the games draw with, as custom properties, so a page can change any of them.
KarakuriGame型The id of a game of the package.
KarakuriMount型The native handle, including its controller and focused keyboard canvas.
mountKarakuri関数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.
MountOptions型Initial native controller, level, layout, keyboard, clock and host callbacks.
Point型A place in a game's own world, in its own units (not pixels).
readTheme関数Reads 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.
Say型A line of words to be said in the player's language: a key of KARAKURI_STRINGS and the values for its {name}s.
Status型How a level stands: still being played, won, or lost.
StatusEvent型What a status callback is given.
Theme型The 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.

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。