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

BodySpectype

What createBody is told. A dynamic body's mass and inertia are worked out from its shapes and density unless given.

Import it

import type { BodySpec } from "@johnmorrisdotca/karakuri/physics";

Definition

interface BodySpec {
    id: string;
    tag?: string;
    type?: BodyType;
    x?: number;
    y?: number;
    shapes: Shape[];
    density?: number;
    restitution?: number;
    friction?: number;
    fixedRotation?: boolean;
    sensor?: boolean;
}

Members

NameTypeDescription
idstring
tag (optional)string | undefined
type (optional)BodyType | undefined
x (optional)number | undefined
y (optional)number | undefined
shapesShape[]
density (optional)number | undefined
restitution (optional)number | undefined
friction (optional)number | undefined
fixedRotation (optional)boolean | undefined

A body that does not turn (a character that stays upright).

sensor (optional)boolean | undefined

Examples

import type { BodySpec } from "@johnmorrisdotca/karakuri/physics";

const spec: BodySpec={id:"ball",shapes:[{kind:"circle",x:0,y:0,r:3}],x:0,y:0};
const value: BodySpec = spec;
console.log(value);
{
  id: 'ball',
  shapes: [ { kind: 'circle', x: 0, y: 0, r: 3 } ],
  x: 0,
  y: 0
}

What it prints (run when this page was built)

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