本文へ移動

Karakuriからくり

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

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

目次

リファレンス · 操作とキャンバスの表示

KarakuriMount型

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

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

インポート

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

定義

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;
}

メンバー

名前型説明
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

例

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

出力(このページを作ったときに実行した結果)

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

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