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

addLinkfunction

Links two nodes at their present distance (or at length) and gives back the link's index.

Import it

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

Definition

function addLink(rig: Rig, a: number, b: number, length_?: number): number

Parameters

NameTypeDescription
rigRig

The mutable native rope nodes, constraints and static geometry.

anumber

The first body or native node index specified by the signature.

bnumber

The second body or native node index specified by the signature.

length_ (optional)number | undefined

Optional rest length; omitted uses the current distance between nodes.

Returns

number

Links two nodes at their present distance (or at length) and gives back the link's index.

Examples

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

const rig=createRig({gravity:0,iterations:1});
addRope(rig,0,0,10,0,2);
console.log(addLink(rig,0,2));
2

What it prints (run when this page was built)

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