Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

Reference · Deterministic 2D physics

addRopefunction

Lays a rope of pieces links from (ax, ay) to (bx, by): the first node is pinned and the last is the node end if one is given (its place is moved to the rope's end), and the nodes between are light. Gives back the indices of the rope's nodes from the pinned end to the other and of its links.

Import it

import { addRope } from "@johnmorrisdotca/karakuri/physics";

Definition

function addRope(rig: Rig, ax: number, ay: number, bx: number, by: number, pieces: number, end?: number): { nodes: number[]; links: number[]; }

Parameters

NameTypeDescription
rigRig

The mutable native rope nodes, constraints and static geometry.

axnumber

The first segment endpoint’s horizontal coordinate.

aynumber

The first segment endpoint’s vertical coordinate.

bxnumber

The second segment endpoint’s horizontal coordinate.

bynumber

The second segment endpoint’s vertical coordinate.

piecesnumber

The positive number of rope segments to create.

end (optional)number | undefined

Optional existing native node index used as the rope’s far endpoint.

Returns

{ nodes: number[]; links: number[]; }

Lays a rope of pieces links from (ax, ay) to (bx, by): the first node is pinned and the last is the node end if one is given (its place is moved to the rope's end), and the nodes between are light. Gives back the indices of the rope's nodes from the pinned end to the other and of its links.

Examples

import { addRope, createRig, length } from "@johnmorrisdotca/karakuri/physics";

console.log(addRope(createRig({gravity:0}),0,0,10,0,2).links.length);
2

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.