Log inGet started
World

Pixel Ledges: 2D Platformer Kit with Sprites, Tilemaps, Wall Jumps and Dash

README.md

api

The front door of the twoDKit: turn a scene into a playable multiplayer 2D platformer in three calls from its build.luau: place a level typed as text, write the player template (body, sprite, controller, pixel-perfect camera, spawn point), and add the HUD. It also re-exports the kit's registries so one require reaches everything.

local PP = require("twoDKit.api")

function content()
    PP.level({ theme = "grassland", text = [[
##############################
#............................#
#..P.....o.....====.......G..#
####..^^..####......M....#####
]] })
    PP.player({ character = "fox", feel = "tight", lives = 3 })
    PP.hud()
end

Building a scene

  • PP.level(opts) -> entity: spawns a Level2D entity (named opts.name, default "Level") with its bottom-left corner at opts.position (default the origin). Passes on text, theme (default grassland), tileset, background, camera, seed, decorations, moverLength, moverTravel, moverSpeed, killDepth, roomWidth, roomHeight.
  • PP.player(opts?) -> { prototype, body, rig, spawn }: writes the scene's player template so every person who joins gets their own: a PlayerPrototype with a body carrying Sprite2D + Player2D (character, default knight; feel, default tight), an owner-only CameraRig with an orthographic Camera driven by Camera2D (camera style, default pixelPerfect; optional targetHeight), and a PlayerSpawn at opts.position or the P of the last PP.level. With lives > 0 it also adds a Trapline.Course (lives, respawn at checkpoints).
  • PP.hud(opts?) -> entity: adds Hud2D (showStyles, default true; title).
  • PP.startOf(text, ox?, oy?) -> { x, y, z }: world position (feet) of the P in level text placed at (ox, oy), or 2 tiles in from the corner.

In play (this peer)

  • PP.localPlayer(): the body this peer controls, or nil until it spawns.
  • PP.setTheme(id): switch every level to a theme (tile set + background).
  • PP.setCharacter(id), PP.setFeel(id): change this peer's player (synced to everyone).
  • PP.setCamera(style): pixelPerfect, smooth or rooms on this peer's camera.

Re-exports

PP.Catalog, PP.Feels, PP.Level, PP.Levels, and PP.registerCharacter, PP.registerTileset, PP.registerBackground, PP.registerTheme, PP.registerFeel (see twoDKit.catalog and twoDKit.feels).