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

Fluidtype

The liquid: its particles and how it behaves.

Import it

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

Definition

interface Fluid {
    particles: Particle[];
    radius: number;
    gravity: number;
    damping: number;
    iterations: number;
    reacts: boolean;
}

Members

NameTypeDescription
particlesParticle[]
radiusnumber

A particle's radius, which is also how far apart two settle (twice this).

gravitynumber
dampingnumber

How much of its speed a particle keeps each step.

iterationsnumber
reactsboolean

Whether water and lava turn each other to stone where they touch.

Examples

import { createFluid, fillRect } from "@johnmorrisdotca/karakuri/physics";
import type { Fluid } from "@johnmorrisdotca/karakuri/physics";

const fluid=createFluid({radius:2,gravity:0,iterations:1,reacts:false});
fillRect(fluid,"water",0,0,8,8);
const value: Fluid = fluid;
console.log(value);
{
  particles: [
    { x: 2, y: 2, px: 2, py: 2, kind: 'water' },
    { x: 6.1, y: 2, px: 6.1, py: 2, kind: 'water' },
    { x: 4.05, y: 6.1, px: 4.05, py: 6.1, kind: 'water' }
  ],
  radius: 2,
  gravity: 0,
  damping: 0.995,
  iterations: 1,
  reacts: false
}

What it prints (run when this page was built)

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