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

linkCrossedfunction

The index of the first live link that the swipe from (x1, y1) to (x2, y2) crosses, or -1. A swipe cuts one link: the nearest to its start.

Import it

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

Definition

function linkCrossed(rig: Rig, x1: number, y1: number, x2: number, y2: number, among?: readonly number[]): number

Parameters

NameTypeDescription
rigRig

The mutable native rope nodes, constraints and static geometry.

x1number

The swipe’s starting horizontal coordinate.

y1number

The swipe’s starting vertical coordinate.

x2number

The swipe’s ending horizontal coordinate.

y2number

The swipe’s ending vertical coordinate.

among (optional)readonly number[] | undefined

Optional native link indices to test instead of the whole rig.

Returns

number

The first crossed alive link’s native index, or -1 when the swipe crosses none.

Examples

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

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

What it prints (run when this page was built)

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