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

stepFluidfunction

Advances the liquid by one step of dt seconds.

Import it

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

Definition

function stepFluid(fluid: Fluid, dt: number, statics: readonly WorldShape[], discs?: readonly Disc[]): void

Parameters

NameTypeDescription
fluidFluid

The mutable native particle fluid.

dtnumber

Elapsed simulated seconds; use STEP for the package’s fixed-step convention.

staticsreadonly WorldShape[]

Native static capsule/circle geometry for the fluid collision step.

discs (optional)readonly Disc[]

Optional moving or interacting native discs.

Examples

import { STEP, countOf, createFluid, fillRect, stepFluid } from "@johnmorrisdotca/karakuri/physics";

const fluid=createFluid({radius:2,gravity:0,iterations:1,reacts:false});
fillRect(fluid,"water",0,0,8,8);
console.log((stepFluid(fluid,STEP,[]),countOf(fluid,"water")));
3

What it prints (run when this page was built)

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