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
| Name | Type | Description |
|---|---|---|
host | HTMLElement | The element that owns this player's canvas and controls. |
options | MountOptions | 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);functionWhat it prints (run when this page was built)