Reference · Controllers and canvas player
KarakuriMounttype
The native handle, including its controller and focused keyboard canvas.
Import it
import type { KarakuriMount } from "@johnmorrisdotca/karakuri/play";
Definition
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;
}
Members
| Name | Type | Description |
|---|---|---|
game | "save-the-character" | "pin-rescue" | "nuts-and-bolts" | "stretch-grabber" | "grid-escape" | "rope-cut" | "tube-sort" | "choice-story" | |
level | number | |
status | Status | |
controller | Controller | The controller of the level being played, for reading its snapshot. |
canvas | HTMLCanvasElement | |
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 |
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 |
destroy | (): void |
Examples
import type { KarakuriMount } from "@johnmorrisdotca/karakuri/play";
const restart = (player: KarakuriMount): void => { player.restart(); player.redraw(); };
console.log(typeof restart);functionWhat it prints (run when this page was built)