-
KERNEL3.3 KB / 4.0 KB gzip
fizlet
createEngine, the shared scheduler, Pool, EventRing, Ledger, seeded random and stats(). Everything else is optional.
const e = createEngine({ root: board, seed: 7 });
e.add({ step(e, dt) {/* sim */}, render(e) {/* DOM */} });
e.start(); // e.destroy() gives the page back
-
INPUT1.3 KB / 1.5 KB gzip
fizlet/input
Keys to named intents with one-frame edges, pointer, a touch stick and on-screen press(). Keys typed in the host's fields never count.
const pad = controls(e, { keys: { fire: ["Space"] } });
if (pad.hit("fire")) fire(); // true for one frame
if (pad.pointer.hit) aim(pad.pointer.x, pad.pointer.y);
-
COLLIDE1.3 KB / 1.5 KB gzip
fizlet/collide
A fixed-capacity spatial hash plus circle, rect and swept segment tests. Pass typed arrays and indices, so nothing boxes.
const grid = new Grid(32, 64, w, h); // cell, cap, world
grid.clear(); grid.add(xs, ys, rs, i); // typed arrays
const n = grid.near(xs, ys, rs, i, out); // ids, once
-
FX2.7 KB / 3.0 KB gzip
fizlet/fx
Pooled particles (struct of arrays), the hero blast(), pop words, scorch marks and screen shake, drawn on a canvas.
const fx = effects({ cap: 420 });
fx.blast(x, y, 1.2); // flash, rings, debris, scorch
fx.step(dt); fx.draw(ctx); // pooled: never allocates
-
SOUND1.0 KB / 1.5 KB gzip
fizlet/sound
Reads the event ring after each frame and plays synth cues, or your own player. Silent until a gesture, and while paused.
const sfx = sound(e, { cues: { boom: "boom" } });
e.events.emit("boom"); // in a step; plays after render
sfx.on = false; // mute
-
EMBED2.0 KB / 2.5 KB gzip
fizlet/embed
Drop a game onto any page: a hex-only palette, easter-egg triggers, lazy load, a toggle key and Escape to give the page back.
embed(() => import("./game.js").then((m) => m.mount), {
name: "blitz", palette: { cmd: "#8573ee" },
easterEgg: { sequence: "konami" } });
-
BOARD UI2.7 KB + 4.6 KB css / 3.0 KB gzip
fizlet/ui
The Battlefield design system as a brick: 3D keys, cards, stickers, overlays and the launch burst. This site is built with it.
applyPalette(root, { sys: "#06c4ff" }); // hex only
press(key, () => fire(), signal); // touch-safe
launch(startKey, start); // press, invert, shatter
-
DEBUG0.5 KB / 1.5 KB gzip
fizlet/debug
Development only: guardLayout() counts every layout read made during a step, the contract's hardest rule, as a number.
import { guardLayout } from "fizlet/debug";
guardLayout(e); // dev builds only
e.violations; // layout reads made in a step: 0