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

addNodefunction

Adds a node and gives back its index.

Import it

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

Definition

function addNode(rig: Rig, x: number, y: number, invMass: number, r?: number): number

Parameters

NameTypeDescription
rigRig

The mutable native rope nodes, constraints and static geometry.

xnumber

The horizontal coordinate or vector component in native units.

ynumber

The vertical coordinate or vector component in native units.

invMassnumber

Inverse mass; zero anchors the node.

r (optional)number

The native node radius.

Returns

number

Adds a node and gives back its index.

Examples

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

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

What it prints (run when this page was built)

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