Pixel Ledges: 2D Platformer Kit with Sprites, Tilemaps, Wall Jumps and Dash
README.md
catalog
The style registry of the twoDKit: every character, tile set, parallax background, theme and camera style it ships, as labelled data, plus the register* functions your own sprite sheets and tile sets join it through. One field switches each style live:
| Style | Shipped ids | Chosen by |
|---|---|---|
| character | knight, robot, fox, mage | Player2D.character / Sprite2D.character |
| tile set | grassland, cave, castle, lab, snow, desert | Level2D.tileset |
| background | grassland, cave, castle, lab, snow, desert | Level2D.background |
| theme (tile set + background) | the ten above | Level2D.theme |
| camera | pixelPerfect, smooth, rooms | Camera2D.style |
Movement feels live in twoDKit.feels. The HUD's style gallery cycles through these lists.
Character sheets
A character is a sprite sheet (default 8 x 8 grid of 32 x 32 frames, facing right) with named animations { row, frames, fps, loop?, col? } (col is the frame a loop restarts from), a collision box in art pixels (bodyWidth, bodyHeight, default 10 x 20) and an accent colour used for the dash after-image. The shipped standard rows are idle, run, jump, fall, wallSlide, dash, land, hurt (rows 0..7). A missing animation falls back along animFallback (wallSlide -> fall -> jump -> idle, dash -> run -> idle, land -> idle, hurt -> fall), so a sheet with only idle and run still works.
API
- Lookups (unknown ids fall back to knight / grassland):
character(id),tileset(id),background(id); tablescharacters,tilesets,backgrounds,themes,camerasand listscharacterList,tilesetList,backgroundList,themeList,cameraList. anim(character, name) -> (Anim?, resolvedName): the animation after fallbacks.registerCharacter(id, t):material(a material on the kit's sprite shader, or a function returning one),frameWidth,frameHeight,columns,rows,anims,bodyWidth,bodyHeight,accent,label,description.registerTileset(id, t):material(an atlas in thetwoDKit.autotilelayout),tile,decorChance,accent,label,description.registerBackground(id, t):layers = { { material, factor, yFactor?, stretch? } }far first (materials on the kit's parallax shader),skyTop,skyBottom.registerTheme(id, tileset, background, label?).resolveStyle(theme, tileset, background) -> (tilesetId, backgroundId):"auto"or""follows the theme.fx(),checkpoint(): the effect and checkpoint flag materials;hexColor("#rrggbb")->{ r, g, b }0..1;PIXELS_PER_UNIT(16).- Gem and checkpoint looks (
Level2D.gemLook,Level2D.checkpointStyle): listsgemLookList(crystal, coin, star, cherry, orb, battery) andcheckpointLookList(flag, lantern, campfire, banner, beacon), tablesgemLooks/checkpointLooks(label, description, sheet row and frame counts), names ingemLookLabels/checkpointLookLabels, lookupsgemLook(id)/checkpointLook(id)(unknown ids fall back to crystal / flag; Trapline's old look names map to the nearest), sheet materialsgemSheet()/checkpointSheet(), painted bytwoDKit.artgen.pickups.
local Catalog = require("twoDKit.catalog")
Catalog.registerCharacter("ninja", {
material = asset.resolve("myArt.ninja", "material"),
frameWidth = 32, frameHeight = 32, columns = 8, rows = 8,
anims = { idle = { row = 0, frames = 4, fps = 6, loop = true }, run = { row = 1, frames = 6, fps = 12, loop = true } },
})
body.component.get("twoDKit.Player2D"):setCharacter("ninja")
Registrations live in this peer's module state: run them on every peer (from a module or component every peer loads) so everyone can draw the new style.