@fogrexon/glyph-arena-body

A platformer body: gravity, a run with acceleration, a jump with coyote time and an input buffer, and axis-separated collision against a solid test you supply. See also package README.

Exports

Generated from the package's source when the docs are built — do not edit this table by hand.

NameKind
Bodytype
BodyConfigtype
BodyInputtype
Boxtype
SolidQuerytype
StepOptionstype
createBodyfunction
jumpHeightOffunction
stepBodyfunction

createBody(box, config)

box is { x, y, w, h } and config is a full BodyConfig: gravity, jumpVelocity, maxFall, coyoteSeconds, jumpBufferSeconds, runSpeed, runAccel, airAccel, groundFriction, airFriction and jumpCutFactor, all required. The body starts with grounded: false, vx and vy at 0, and keeps the config it was made with.

const body = createBody({ x: 70, y: 120, w: 20, h: 28 }, config);

stepBody(body, input, dt, solid, options?)

stepBody(body, { right: true, jumpHeld: true }, delta, solid, { grid: 32 });

grounded is recomputed from the vertical move every step and never carried over, so a body that walks off a ledge is not grounded on the frame it leaves.

jumpHeightOf(config)

v² / 2g in px, from the same config stepBody uses, so a spec and an acceptance run cannot quote two different numbers.

jumpHeightOf(config); // 111.08 for gravity 2600, jumpVelocity -760

What it deliberately does not have

This package does not import sibling @fogrexon/glyph-arena-* packages.