Skip to content

Reference

The full public surface of @f0rbit/forge — every export across the five subpaths, with kind, signature, and a one-line description. Sourced from a typed data/exports.ts module that doubles as the data behind /llms.txt.

For LLM consumption, fetch the plain-text version at /forge/llms.txt. For deep-dive prose, follow the per-topic pages in the sidebar.

Total exports: 235 across 6 subpaths.

@f0rbit/forge

Engine kernel — ECS, schedule, time, rng, resources, input, replay, anim, snapshot, palette, debug.

World

Sparse-set ECS with typed components and queries.

NameKindSignatureDescription
worldfactory() => WorldCreate a fresh world. Returns { spawn, despawn, has, get, set, remove, query, count, ... }.
componentfactory<T>(name: string) => Component<T>Create a typed component descriptor backed by a global symbol (Symbol.for).
internalconstantunique symbolEscape-hatch key for World[internal]. Used by snapshot/restore and tests.
pos_cconstantComponent<{ x: number; y: number }>Canonical position component used by PIXI sprite + anim sync systems.
world.spawn_manyfunction(count, factory) | (specs) => readonly Id[]Bulk-spawn entities. Two forms: `(count, factory)` calls `factory(i)` for `i` in `[0, count)`; `(specs[])` spawns one entity per element of the array. Returns ids in spawn order.
world.despawn_markedfunction(...markers: readonly Component<any>[]) => numberBulk-despawn every entity that has ALL of the given marker components. Snapshots before mutating; safe to call mid-iteration of unrelated queries. Returns count despawned.
world.queryfunction<C>(cs: C, opts?: QueryOpts) => Query<C>Query the world. `Component<true>` markers are auto-elided from the yielded tuple, so the destructure shape is only the data components plus `Id`.
WorldtypeCore ECS interface returned by world().
ComponenttypeComponent<T>Branded descriptor pairing a name, key, and data type.
IdtypeBranded number identifying an entity.
QuerytypeQuery<C>Iterable query result with .each and .collect helpers. Marker components are elided from the yielded tuple.
QueryOptstype{ without?: Component<any>[] }Optional excludes for query().
ComponentTupletypeHelper that maps a tuple of Component<T> to a tuple of T (markers elided).
SpawnFactorytype(i: number) => readonly [Component<any>, any][]Factory passed to `spawn_many(count, factory)`.
WorldInternaltypeEscape-hatch interface exposing internal stores + `spawn_at` for snapshot/restore.

Schedule

Insertion-ordered system runner with named stages.

NameKindSignatureDescription
schedulefactory() => ScheduleCreate a schedule. Default stages: startup, pre, update, post, render.
schedule.addfunction(stage: Stage, sys: System, opts?: AddOpts | string) => ScheduleRegister a system. Pass a string for a name, or `{ every?, phase?, name? }` to gate by tick modulus. `every: 1` runs every tick; `every: N` runs every Nth tick offset by `phase`.
Scheduletype{ add, remove, tick, run, stages }.
Stagetype"startup" | "pre" | "update" | "post" | "render" | stringBuilt-in or custom stage name.
Systemtype(w: World, ctx: Ctx) => voidA system function — receives the world and the per-tick context.
AddOptstype{ every?: number; phase?: number; name?: string }Options for schedule.add. `every` gates the system to every Nth tick; `phase` offsets the gate so two periodic systems can interleave.
Ctxtype{ time, rng, res, input, debug, palette, store? }Per-tick context handed to every system.

Time

Deterministic fixed-step time resource.

NameKindSignatureDescription
timefactory(opts?: { fixed_dt?: number }) => TimeCreate a time resource. Default fixed_dt = 1/60.
Timetype{ tick, fixed_dt, elapsed, alpha, scale, advance, restore }Fixed-step accumulator + scale + alpha.

RNG

Seeded splittable random.

NameKindSignatureDescription
rngfactory(seed: number) => RngCreate a seeded RNG. Use .fork() for per-subsystem isolation.
Rngtype{ seed, next, int, pick, fork, state, restore }Splittable PRNG. Same seed + same call sequence = same output.

Resources

Symbol-keyed registry for shared engine state.

NameKindSignatureDescription
resourcesfactory() => ResourcesCreate a resources registry.
resourcefactory<T>(name: string) => ResKey<T>Create a typed resource key (uses Symbol.for for cross-bundle identity).
Resourcestype{ has, get, set, delete }.
ResKeytypeResKey<T>Typed key for resources.get/set.

Animation

Per-entity sprite animation, atlas registry, and event buffer.

NameKindSignatureDescription
animfactory() => AnimAnimation system controller — play, stop, advance, snapshot.
anim_cconstantComponent<AnimData>Per-entity animation state component. The `t` field is an internal accumulator (tracked for snapshot determinism); never read or write it from game code.
atlas_registry_rconstantResKey<AtlasRegistry>Resource key for the registered atlas sequences. Renamed from `atlas_registry` in v0.3.0 for `_r` suffix consistency.
anim_events_rconstantResKey<AnimEventBuffer>Resource key for the per-tick anim event buffer. Renamed from `anim_events` in v0.3.0 for `_r` suffix consistency.
AnimtypeAnimation controller interface.
AnimDatatypePer-entity animation state (sequence, frame, time, speed). The `t` field is internal — used for snapshot/restore determinism only.
AnimEventtypeAnim event union — frame_changed, finished, looped.
AnimEventBuffertypePer-tick buffer of animation events; cleared each schedule.tick.
AtlasFrametypeSingle frame in an atlas — texture alias + duration.
AtlasRegistrytypeMap of alias → AtlasSequences.
AtlasSequencestypeMap of sequence name → AtlasFrame[].

Follow

Parent-child primitive — follower's pos = target.pos + offset every tick.

NameKindSignatureDescription
follow_cconstantComponent<Follow>Per-entity follow component — `{ target, offset }`. Spawn alongside `pos_c` to attach an entity's position to another entity's position with an x/y offset.
follow_systemfactory(pos_component: Component<{ x, y }>) => SystemSystem that writes `target.pos + offset` back into each follower's pos every tick. Wired into `boot()` post-stage automatically; pass `opts.pos` to override the position component (defaults to `pos_c`). Silently skips followers whose target was despawned.
Followtype{ target: Id; offset: { x: number; y: number } }Follow component data — id of the entity to track and a fixed x/y world-space offset.

Input

Action-based input layer with bindings, sources, and rebinding.

NameKindSignatureDescription
inputfactory(bindings?: Bindings) => InputCreate an input system. Pair with a source via input.source(...).
noop_sourcefactory() => InputSourceSource that emits nothing — useful for tests.
scriptedfactory(events) => InputSourceSource that replays scripted RawInput events at given ticks.
tickedfactory(fn) => InputSourceWrap a per-tick function as an input source.
empty_bindingsfactory() => BindingsEmpty bindings object — { digital: {}, axes: {}, deadzone: 0.15 }.
merge_bindingsfactory(...bs: Bindings[]) => BindingsMerge bindings layers; later layers override earlier.
Inputtype{ bind, source, advance, pressed, just_pressed, just_released, axis, vector, ... }.
ActionStatetypePer-action edge + value state.
RawInputtypeRaw event union — key, pad button, pad axis.
InputSourcetype{ poll, dispose? } interface for input producers.
PadIndextypeBranded gamepad index (0–3).
Bindingstype{ digital, axes, deadzone } — declarative action map.
TriggertypeSingle digital trigger — key | pad.button | pad.axis.
AxisBindingtypeSingle axis binding — key.pair | pad.axis | pad.button.pair.
ActiontypeAction name string.

Replay

Deterministic record/playback of action events.

NameKindSignatureDescription
replaynamespace{ record, play, save, load }Namespace bundling recorder, player, and save/load helpers. The schema lives at the top-level `replay_schema` export.
replay_schemaschemaZodType<ReplayDoc>Top-level Zod schema for a replay document. Use directly for validation or to derive types via `z.infer`.
replay.recordfunction(input: Input, ctx: Ctx, opts?: { seed?: number }) => RecorderRecord action transitions into a `ReplayDoc`. Reads `seed`, `fixed_dt`, `get_tick` from `ctx`. A low-level overload `(input, { seed, fixed_dt, get_tick })` is available for tests without a `Ctx`.
ReplayDoctypeSerialised replay document — meta + events.
ActionEventtype{ tick, action, kind, value? } event row.
ReplayErrortypeReplay error union — parse, mismatch, etc.
Recordertype{ record, snapshot, dispose } recorder handle.
Playertype{ apply, exhausted } player handle.

Snapshot

Persistence kernel — serialise and restore world + resources.

NameKindSignatureDescription
snapshotterfactory(opts?) => SnapshotterCreate a snapshotter. Provides take() and restore().
snapshot_schemaschemaZodType<Snapshot>Zod schema for a snapshot document.
SnapshottypeSerialised world + resources blob.
SnapshotMetatype{ version, created_at, ... } header.
EntitySnaptypePer-entity row in a Snapshot.
Snapshottertype{ take, restore }.
TakeOptstypeOptions for snapshotter.take().
RestoreOptstypeOptions for snapshotter.restore().

Storage (re-exports)

Convenience re-exports from @f0rbit/forge/storage.

NameKindSignatureDescription
memfactory<T>(opts?: MemOpts<T>) => Store<T>In-memory Store<T> backend.
filefactory<T>(opts: FileOpts<T>) => Store<T>File-system Store<T> backend (Node).
storefactory<T>(opts: StoreOpts<T>) => Store<T>Generic Store<T> with custom IO.
savefunction(snapshotter, store, slot) => Promise<Result<void, SaveError>>Compose snapshotter + store: take a snapshot and persist it to a slot.
loadfunction(snapshotter, store, slot) => Promise<Result<void, SaveError>>Compose snapshotter + store: load a slot and restore the world.
engine_storefactory(opts?: EngineStoreOpts) => EngineStoreDefault engine store wrapping bindings + prefs persistence.
bindings_schemaschemaZod schema for persisted Bindings.
prefs_schemaschemaZod schema for persisted Prefs.
default_prefsconstantPrefsSensible default preferences object.
StoretypeStore<T>Generic persisted-store interface.
SlottypeBranded slot identifier (string).
SaveHandletypeHandle returned by store.open(slot).
SaveSlottypeSlot + value pair.
StoreErrortypeStore error union.
MemOptstypeOptions for mem().
FileOptstypeOptions for file().
StoreOptstypeOptions for store().
SaveErrortypeError union for save/load.
EngineStoretypeDefault-engine save layer.
EngineStoreOptstypeOptions for engine_store().
PrefstypeUser-facing engine preferences.

Debug

Frame-buffered draw commands, per-entity pins, and __DEV__ gating.

NameKindSignatureDescription
debugfactory(opts?: DebugOpts) => DebugCreate a debug subsystem. Use __dev__ to toggle production no-op.
debug_noopfactory() => DebugNo-op debug — drops every command. Used in production builds.
is_devfunction() => booleanRead the __DEV__ gate from the global.
Debugtype{ line, rect, text, pin, unpin, frame, stats, ... }.
DebugOptstypeOptions for debug().
DebugCmdtypeFrame-buffered draw command union.
DebugStatstype{ entities, frame_ms, draw_calls, ... }.
PintypePer-entity inspection pin.
PinKindtypePin classification — info, warn, error.
ColortypeNumeric RGB triple or named colour.
InspectiontypeInspector snapshot for a single entity.
ComponentInspectiontypePer-component inspection row.

Palette

Command palette — register, search, run.

NameKindSignatureDescription
palettefactory(opts?: PaletteOpts) => PaletteCreate a command palette controller.
palette_noopfactory() => PaletteNo-op palette for production.
builtinsfunction(deps: BuiltinDeps) => Command[]Built-in commands (toggle pause, set time scale, snapshot, ...).
tokenisefunction(line: string) => string[]Tokenise a palette command line.
parse_linefunction(line: string) => ParsedLineParse a tokenised line into command + args.
fuzzy_scorefunction(query: string, target: string) => numberFuzzy match score (0..1).
fuzzy_rankfunction(query, items) => SearchHit[]Rank items by fuzzy score against a query.
Palettetype{ register, run, search, history, ... }.
PaletteOptstypeOptions for palette().
CommandtypeCommand<A>Registered command — id, label, run.
CommandErrortypeCommand run error.
CommandRunnertypeCommandRunner<A>(args: A, ctx: Ctx) => Result<void, CommandError>.
SearchHittypeSearch result row — { id, score }.
BuiltinDepstypeDependencies needed by builtins().
ParsedLinetype{ command, args } parsed from a palette line.

Math

Tiny vector helpers.

NameKindSignatureDescription
vec2factory(x: number, y: number) => Vec2Create a Vec2 record.
Vec2type{ x: number; y: number }Plain 2D vector record.

Errors

Engine-wide error union.

NameKindSignatureDescription
EngineErrortypeDiscriminated union of every kernel error kind. Used in Result<T, EngineError>.

Test harness

Headless test driver — run schedules, assert, snapshot.

NameKindSignatureDescription
harnessfactory(opts?: HarnessOpts) => HarnessCreate a headless harness for integration tests. Wires world, schedule, time, rng, resources, input.
Harnesstype{ world, schedule, time, rng, res, input, tick, run, dispose }.
HarnessOptstypeOptions for harness() — seed, fixed_dt, bindings, resources.

Version

NameKindSignatureDescription
VERSIONconstant"0.0.1"Compile-time package version constant.

@f0rbit/forge/pixi

PIXI v8 integration — boot(), camera, sprite + anim sync, palette UI, debug overlay. The only subpath allowed to import pixi.js.

Boot

Wire-up factory that returns a fully-composed App.

NameKindSignatureDescription
bootfactory(opts: BootOpts) => Promise<Result<App, BootError>>Mount, wire renderer + camera + assets + input + palette + debug, return a started App.
ApptypeStarted application handle — { world, schedule, ..., tick, start, stop, dispose }.
BootOptstypeBoot options — mount, camera, bindings, assets, dev gate, optional overrides.
BootErrortypeBoot error union — mount_not_found, render_failed, asset_failed.
AssetSpectype{ kind: 'image' | 'atlas', alias, url } asset descriptor.

Assets

PIXI asset loader with atlas registry integration.

NameKindSignatureDescription
assetsfactory(opts?: AssetsOpts) => AssetsCreate the asset loader. Provides load(kind, alias, url), texture(alias), atlas(alias), registry().
assets.loadfunction<K extends AssetKind>(kind: K, alias: string, url: string) => Promise<Result<LoadValue<K>, AssetError>>Async loader unified by `kind` discriminator. `kind: 'image'` returns `Texture`; `kind: 'atlas'` returns `Spritesheet`. Replaces the old separate `image()`/`atlas()` async loaders.
assets.texturefunction(alias: string) => Result<Texture, AssetError>Synchronous getter for a previously-loaded image. `kind: 'not_loaded'` if the alias is unknown.
assets.atlasfunction(alias: string) => Result<Spritesheet, AssetError>Synchronous getter for a previously-loaded atlas. `kind: 'not_loaded'` if the alias is unknown.
Assetstype{ load, texture, atlas, get, has, register_atlas, registry, dispose }.
AssetsOptstype{ fixed_dt, register_default? } options.
AssetKindtype"image" | "atlas"Discriminator for `assets.load`.
LoadValuetypeLoadValue<K> = K extends 'image' ? Texture : SpritesheetConditional return type for `assets.load<K>`.
AssetErrortypeAsset error union — load_failed, not_loaded, invalid_atlas, wrong_kind.

Browser source

Keyboard + Gamepad + (optional) pointer InputSource.

NameKindSignatureDescription
browser_sourcefactory(opts?: BrowserSourceOpts) => BrowserSourceInputSource that polls keyboard + Gamepad API.
BrowserSourcetype{ poll, dispose }.
BrowserSourceOptstype{ deadzone?, get_time? } options.

Camera

Design-resolution camera with letterbox/stretch/integer modes.

NameKindSignatureDescription
camerafactory(opts: CameraOpts) => CameraCreate a camera. Modes: letterbox, stretch, integer, fit.
Cameratype{ resize, viewport, set_mode, design, ... }.
CameraOptstype{ design: { width, height }, mode } options.
CameraModetype"letterbox" | "stretch" | "integer" | "fit"Camera scaling mode.
Viewporttype{ x, y, w, h, scale } resolved viewport rect.

Render

Application + stage + overlay layers.

NameKindSignatureDescription
make_renderfactory(opts: RenderOpts) => Promise<Result<RenderState, RenderError>>Initialise the PIXI Application and overlay containers.
RenderStatetype{ app, world, debug_overlay, palette_overlay, render_system, canvas, dispose }.
RenderErrortypeRender init error — webgl_unavailable, ...
RenderOptstype{ mount, camera } options.

Sprite

ECS↔PIXI sprite bridge.

NameKindSignatureDescription
sprite_cconstantComponent<SpriteData>Per-entity sprite component (texture, frame, anchor, tint, scale, visibility).
sprite_sync_systemfactory(opts: SpriteSystemOpts) => SystemSystem that syncs sprite_c to PIXI display objects each post-tick. Applies texture/frame, anchor, tint, scale, position, zIndex. Owns the `WeakMap<World, Map<Id, Sprite>>` keeping live PIXI nodes.
spritenamespace{ set, show, hide }Patch helpers for `sprite_c` — `sprite.set(w, id, patch)` merges a `Partial<SpriteData>` into the existing component (no spread ceremony). `sprite.show`/`hide` toggle `visible`.
sprite.setfunction(w: World, id: Id, patch: Partial<SpriteData>) => Result<void, EngineError>Read the entity's `sprite_c`, merge `patch`, write back. Errors `component_missing` if the entity has no sprite.
sprite.showfunction(w: World, id: Id) => Result<void, EngineError>Shortcut for `sprite.set(w, id, { visible: true })`.
sprite.hidefunction(w: World, id: Id) => Result<void, EngineError>Shortcut for `sprite.set(w, id, { visible: false })`.
SpriteDatatypeConfig-only: `{ texture, frame?, anchor?, tint?, visible?, z?, scale?, alpha? }`. The PIXI runtime node is owned by `sprite_sync_system` (private `WeakMap`); no `node` field on the public type.
SpriteData.scaletype{ x: number; y: number }Optional non-uniform scale applied to the underlying PIXI Sprite each frame. Defaults to (1,1). Use for HUD vs world sprite ratios, pixel-perfect upscale, mirroring (`{ x: -1, y: 1 }`).
SpriteData.alphatypenumberOptional 0..1 alpha applied to the underlying PIXI Sprite each frame. Default 1.0 (fully opaque). Pair with `Grid.lit_area` to drive gradient FOV — set per-tile sprite alpha from the lit-area intensity.
SpriteSystemOptstype{ assets, world_container, pos_component } options.

Anim

Animation sync — drives sprite frames from anim_c.

NameKindSignatureDescription
anim_sync_systemfactory(opts: AnimPixiOpts) => SystemSystem that reads anim_c, advances frames, writes back to sprite_c.
AnimPixiOptstype{ assets } options.

Debug overlay

Renders frame-buffered debug commands into a PIXI overlay.

NameKindSignatureDescription
debug_pixifactory(opts: DebugPixiOpts) => SystemSystem that renders Debug.frame() commands into the debug overlay each render-tick.
DebugPixiOptstype{ overlay, dev? } options.

Palette UI

PIXI overlay UI for the command palette.

NameKindSignatureDescription
palette_pixifactory(opts: PalettePixiOpts) => { system: System, dispose: () => void }Mount a PIXI palette overlay; returns the per-frame system + dispose.
PalettePixiOptstype{ overlay, palette, get_ctx } options.

@f0rbit/forge/debug

Standalone debug subsystem (also re-exported from the main entry).

Factories

NameKindSignatureDescription
debugfactory(opts?: DebugOpts) => DebugCreate a debug subsystem.
debug_noopfactory() => DebugNo-op debug for production.
is_devfunction() => booleanRead the __DEV__ global.

Types

NameKindSignatureDescription
Debugtype{ line, rect, text, pin, unpin, frame, stats, ... }.
DebugOptstypeOptions for debug().
ColortypeNumeric RGB triple or named colour.
DebugCmdtypeFrame-buffered draw command union.
DebugStatstype{ entities, frame_ms, draw_calls, ... }.
PintypePer-entity inspection pin.
PinKindtypePin classification.
ComponentInspectiontypePer-component inspection row.
InspectiontypeInspector snapshot.

@f0rbit/forge/storage

Persistence subsystem — snapshotter, generic Store<T>, save/load helpers, default engine store.

Snapshot

NameKindSignatureDescription
snapshotterfactory(opts?) => SnapshotterCreate a snapshotter.
snapshot_schemaschemaZod schema for snapshots.
SnapshottypeSerialised world + resources.
SnapshotMetatypeSnapshot header.
EntitySnaptypePer-entity row.
Snapshottertype{ take, restore }.
TakeOptstypeOptions for take().
RestoreOptstypeOptions for restore().

Backends

Store<T> implementations.

NameKindSignatureDescription
memfactory<T>(opts?: MemOpts<T>) => Store<T>In-memory backend — useful for tests.
filefactory<T>(opts: FileOpts<T>) => Store<T>File-system backend (Node).
storefactory<T>(opts: StoreOpts<T>) => Store<T>Generic backend with custom read/write.
StoretypeStore<T>{ open, save, load, list, delete }.
SlottypeBranded slot identifier.
SaveHandletypeSlot handle.
SaveSlottypeSlot + value pair.
StoreErrortypeStore error union.
MemOptstypeOptions for mem().
FileOptstypeOptions for file().
StoreOptstypeOptions for store().

Save / load

NameKindSignatureDescription
savefunction(snapshotter, store, slot) => Promise<Result<void, SaveError>>Compose snapshotter + store: persist current world to a slot.
loadfunction(snapshotter, store, slot) => Promise<Result<void, SaveError>>Compose snapshotter + store: load a slot back into the world.
SaveErrortypeError union for save/load.

Engine store

Bindings + prefs persistence layer used by boot().

NameKindSignatureDescription
engine_storefactory(opts?: EngineStoreOpts) => EngineStoreDefault engine save layer wrapping bindings + prefs.
bindings_schemaschemaZod schema for persisted Bindings.
prefs_schemaschemaZod schema for persisted Prefs.
default_prefsconstantPrefsSensible default Prefs object.
EngineStoretype{ bindings, prefs } persistence handle.
EngineStoreOptstypeOptions for engine_store().
PrefstypeUser-facing engine preferences.

@f0rbit/forge/grid

Grid-game primitives — pure cell math, Bresenham line, line-of-sight FOV, cell-keyed spatial index, axis-sliding tile movement, and tick/cell-rate calibration. Tree-shakeable; non-grid consumers pay nothing.

Grid

Cell math factory + spatial methods on the returned `Grid` record.

NameKindSignatureDescription
gridfactory(opts: GridOpts) => GridBuild a Grid record bundling cell↔world conversion, key/unkey, neighbours, distances, and the spatial methods (line, line_of_sight, move_tile).
grid.linefunction(a: Cell, b: Cell) => Generator<Cell>Bresenham line generator yielding every cell from `a` to `b` inclusive. Method on `Grid` — call as `g.line(a, b)`.
grid.line_of_sightfunction(opts: FovOpts) => ReadonlySet<number>Symmetric Bresenham FOV — returns visible cell-keys from `opts.from` within Chebyshev radius. Method on `Grid` — call as `g.line_of_sight({...})`.
grid.lit_areafunction(opts: LightOpts) => Map<number, number>Gradient FOV — same Bresenham LOS test as `line_of_sight`, but returns a `Map<key, intensity>` where intensity is a float in [0, 1]. Default falloff is linear `1 - distance/radius`. Pass a custom `falloff` for quadratic / smoothstep / torch flicker. Origin is always 1.0.
grid.move_tilefunction<P>(w: World, id: Id, dir: { dx, dy }, opts: TileMoveOpts<P>) => Result<TileMoveResult, EngineError>Step entity one cell with axis-sliding collision. Method on `Grid`. `opts.pos` defaults to forge's canonical `pos_c`; pass it for custom position components.
Celltype{ readonly x: number; readonly y: number }Integer-coordinate cell. Value object — pass by value.
Gridtype{ cols, rows, tile, key, unkey, in_bounds, cell_to_world, world_to_cell, chebyshev, manhattan, neighbors4, neighbors8, line, line_of_sight, move_tile }Grid helper bundle returned by grid().
GridOptstype{ cols: number; rows: number; tile: number }Options for grid() — `tile` is pixels per cell (square tiles).
FovOptstype{ from: Cell; radius: number; is_blocking: (cell: Cell) => boolean; include_origin?: boolean }Options for `grid.line_of_sight`. `include_origin` defaults to true. (No `grid` field — the method closes over the receiver.)
LightOptstype{ from: Cell; radius: number; is_blocking: (cell: Cell) => boolean; falloff?: (distance: number, max: number) => number }Options for `grid.lit_area`. `falloff` defaults to linear `(d, max) => 1 - d/max`. Custom falloffs are clamped to [0, 1].
TileMoveOptstype{ blocked_by: (cell: Cell) => boolean; slide?: boolean; pos?: Component<P> }Options for `grid.move_tile`. `slide` defaults to true. `pos` defaults to forge's `pos_c`; override for custom position components.
TileMoveResulttype{ from: Cell; to: Cell; moved: boolean }Result of `grid.move_tile` — gives consumers the resolved cell so they can react (e.g. did I just step onto the exit?).

Spatial index

Cell-keyed spatial lookup over an entity component.

NameKindSignatureDescription
grid_indexfactory<P>(w: World, pos_c: Component<P>, grid: Grid, filter?: Component<any>) => GridIndexBuild a cell-keyed spatial index over entities with `pos_c`. Optional marker `filter` restricts the indexed set. Eagerly refreshes on construction.
grid_index_sync_systemfactory(idx: GridIndex) => SystemSystem that calls `idx.refresh()` once per tick. Add to `pre` so subsequent systems see fresh lookups.
GridIndextype{ at, all_at, around, refresh }Spatial index interface — `at(cell)` first match, `all_at(cell)` all matches, `around(cell, r)` everything in a Chebyshev-r square, `refresh()` rebuild.

Timing

Calibrate movement speed in cells/sec instead of ticks-per-step.

NameKindSignatureDescription
ticks_per_stepfunction(cells_per_second: number, fixed_dt: number) => numberConvert a desired cells-per-second to the integer tick gate. Decouples movement speed from grid resolution.

@f0rbit/forge/presets

Pre-built Bindings for common control schemes — hand to boot() or merge with custom bindings.

Built-in presets

Each preset is a Bindings object covering keyboard + gamepad.

NameKindSignatureDescription
presets.movement_2dconstantBindings2D analogue movement: move.x, move.y axes (WASD / arrows / left stick / d-pad). Renamed from `movement2d` in v0.3.0.
presets.movement_4wayconstantBindings4-way digital-only movement: move.{left,right,up,down}. No axes — ideal for tile-step games. Renamed from `movement_4way_digital` in v0.3.0.
presets.movement_8wayconstantBindings8-way digital movement: move.{left,right,up,down} digital + move.x, move.y axes. Renamed from `movement8way` in v0.3.0.
presets.platformerconstantBindingsSide-scroller: jump (digital, Space / pad south) + move.x axis.
presets.twinstickconstantBindingsTwin-stick shooter: move.x, move.y, aim.x, aim.y axes.
presets.menuconstantBindingsMenu navigation: up, down, left, right, confirm, cancel digital actions.