Pixel Ledges: 2D Platformer Kit with Sprites, Tilemaps, Wall Jumps and Dash
README.md
traps
The hazards and power-ups a twoDKit level gets from its text, beyond spikes (^) and gems (o). Level2D builds and animates them on every peer from the same text; Player2D asks it whether its body was hit by a hazard (the kill goes through Trapline exactly as spikes do, so lives, checkpoints, respawn and the HUD keep working) and which power-ups it touched.
| char | kind | what it does |
|---|---|---|
W | saw | a spinning 2-tile buzzsaw centred on its cell; costs a life within SAW_RADIUS (0.78 tiles) of its centre |
L | lava | an animated pool; the top cell of a column rolls and bubbles. Costs a life below LAVA_DEPTH (0.6) of a top cell, anywhere in a cell under lava |
X | crumble | collides like ground; shakes when a player stands on it, falls away after CRUMBLE.shake (0.5 s), comes back after CRUMBLE.gone (3 s) once nobody is in its cell |
F | jet | a steel block that throws a flame up to JET.reach (3) tiles away from the solid it is mounted on (up when the cell above is free, else down, right, left). On the shared Trapline clock: cold, then a warning sputter, then fire (JET.period 3 s, warn 1.4, on 1.9). Costs a life in the flame |
H | heart | restores one Trapline life when lives are on and not full; taken once per run (like a gem). Grey and skipped while lives are full or off |
D | crystal | refills the dash (Celeste style) when it is not full; grows back after CRYSTAL_RESPAWN (1 s) |
T | spring | bounces the player SPRING_HEIGHT (6.5) tiles up and refills the dash |
Multiplayer
Nothing here is synced. Every peer builds the same traps from the same text, and fire jets and saws run on Trapline's shared clock (TL.now), so they are in step everywhere. Crumbling blocks watch every player body's feet on each peer (the owner's own and the replicated others), so a block breaks for everyone when anyone stands on it. Power-ups are each player's own, as gems are: a heart one player took is still there for the others, and a crystal regrows per player. Player2D writes a synced boost field when its body takes one, so every peer plays the moment (effect and sound) and the spring's bounce.
API
index(grid): the level's traps by kind, cached per grid; jets carrydirandcells.jetDir(grid, x, y),jetCells(grid, x, y),jetState(t)-> "off" | "warn" | "on".lavaTop(grid, x, y),hazardIn(grid, x0, y0, x1, y1, t)(level-local box) andhazardHit(x0, y0, x1, y1, t?)(world box, every running level): the hazard's label ("Saw blade", "Lava", "Fire jet") or nil.crumbleStep(state, stood, blocked, dt): the crumbling block's state machine; returns "shake", "break", "restore" or nil.spring(st, feel),refillDash(st, feel): what a spring and a crystal do to atwoDKit.motorstate.touch(st, body, feel, collected): the power-ups a body touches now, applied; returns{ kind, level, index, x, y }for each.build(levelId, parent, grid),animate(levelId, dt, ctx),destroy(levelId): whatLevel2Dcalls.clock(): the shared clock the hazards run on.
Art: twoDKit.artgen.hazards paints art/fx/hazards, art/fx/buzzsaw and art/fx/powerups (rows in Traps.ROWS).