Log inGet started
World

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:

StyleShipped idsChosen by
characterknight, robot, fox, magePlayer2D.character / Sprite2D.character
tile setgrassland, cave, castle, lab, snow, desertLevel2D.tileset
backgroundgrassland, cave, castle, lab, snow, desertLevel2D.background
theme (tile set + background)the ten aboveLevel2D.theme
camerapixelPerfect, smooth, roomsCamera2D.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); tables characters, tilesets, backgrounds, themes, cameras and lists characterList, 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 the twoDKit.autotile layout), 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): lists gemLookList (crystal, coin, star, cherry, orb, battery) and checkpointLookList (flag, lantern, campfire, banner, beacon), tables gemLooks / checkpointLooks (label, description, sheet row and frame counts), names in gemLookLabels / checkpointLookLabels, lookups gemLook(id) / checkpointLook(id) (unknown ids fall back to crystal / flag; Trapline's old look names map to the nearest), sheet materials gemSheet() / checkpointSheet(), painted by twoDKit.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.