本文へ移動

Meikyuu迷宮

シード付きの迷路と矢印パズルを作り、番号付きの問題を進め、平面や立体表面で遊べます。

「迷宮」は迷路のように入り組んだ場所を表す言葉です。 名前について(英語)

目次

リファレンス · 遊べる立体表面の迷路

SolidMount型

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

The mounted surface maze, game, rotation/zoom controls, native progress and cleanup handle.

インポート

import type { SolidMount } from "@johnmorrisdotca/meikyuu/3d/play";

定義

type SolidMount = {
    readonly host: HTMLElement;
    recipe: () => SolidRecipe;
    maze: () => SolidMaze;
    mazeGame: () => MazeGame<SolidMaze>;
    load: (recipe: string | SolidRecipe) => boolean;
    set: (changes: MazeLook & {
        tap?: boolean;
        sound?: boolean;
        hints?: boolean;
        banner?: boolean;
        language?: MeikyuuLanguage;
        stones?: StoneOption;
        edgeTurn?: boolean;
    }) => void;
    undo: () => void;
    restart: () => void;
    hint: () => void;
    turn: (by: "left" | "right" | "up" | "down" | {
        right?: number;
        down?: number;
    }) => void;
    faceMe: (cell?: number) => void;
    zoomIn: () => void;
    zoomOut: () => void;
    fit: () => void;
    turnMode: (on?: boolean) => boolean;
    edgeTurn: (on?: boolean) => boolean;
    view: (to?: {
        q?: Quat;
        zoom?: number;
    }) => {
        q: Quat;
        zoom: number;
    };
    place: (cell: number) => SolidCellPlace;
    between: (a: number, b: number) => {
        x: number;
        y: number;
    } | null;
    pick: (x: number, y: number) => number;
    stoneMode: (on?: boolean) => boolean;
    stones: () => readonly number[];
    stonesLeft: () => number | null;
    stone: (cell: number) => StoneVerdict;
    clearStones: () => void;
    run: () => string;
    restore: (code: string) => boolean;
    destroy: () => void;
};

メンバー

名前型説明
hostHTMLElement
recipe() => SolidRecipe
maze() => SolidMaze
mazeGame() => MazeGame<SolidMaze>
load(recipe: string | SolidRecipe) => boolean

Play another maze. Returns false for a recipe that is none.

set(changes: MazeLook & { tap?: boolean; sound?: boolean; hints?: boolean; banner?: boolean; language?: MeikyuuLanguage; stones?: StoneOption; edgeTurn?: boolean; }) => void
undo() => void
restart() => void
hint() => void
turn(by: "left" | "right" | "up" | "down" | { right?: number; down?: number; }) => void

Turn the solid a step: left, right, up or down, or by radians (right, down). Smooth unless the page asks for less motion.

faceMe(cell?: number) => void

Bring a cell round to face you; the end of the line by default, or the start before there is a line.

zoomIn() => void
zoomOut() => void
fit() => void

Back to the zoom that fits the box.

turnMode(on?: boolean) => boolean

Whether every one-finger drag turns the solid; with an argument, turn that on or off.

edgeTurn(on?: boolean) => boolean

Whether the solid turns by itself near the edge of the side in view; with an argument, turn that on or off.

view(to?: { q?: Quat; zoom?: number; }) => { q: Quat; zoom: number; }

How the solid is turned now (a quaternion [x, y, z, w]) and zoomed. With an argument, turn it so at once.

place(cell: number) => SolidCellPlace

Where a cell is now, on the picture.

between(a: number, b: number) => { x: number; y: number; } | null

Where the edge between two cells that are beside each other is now, in the middle, on the picture (the line crosses from one to the other there), or null for two that are not.

pick(x: number, y: number) => number

The cell at a point of the box (pixels from its top left), or -1.

stoneMode(on?: boolean) => boolean
stones() => readonly number[]
stonesLeft() => number | null
stone(cell: number) => StoneVerdict
clearStones() => void
run() => string
restore(code: string) => boolean
destroy() => void

例

import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
import type { SolidRecipe } from "@johnmorrisdotca/meikyuu/3d";
import type { SolidMount } from "@johnmorrisdotca/meikyuu/3d/play";
import { mountSolid } from "@johnmorrisdotca/meikyuu/3d/play";

const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const grid = maze.grid;
const solidRecipe: SolidRecipe = {kind:"cube",n:2,algorithm:"backtracker",seed:42};
const host = document.createElement("div");
document.body.append(host);
const player: SolidMount | null = mountSolid(host,{recipe:solidRecipe});
console.log(player?.maze().grid.cells);
player?.destroy();

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

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