Log inGet started
World

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

README.md

juice

twoDKit's game feel in one place. Every moment a player has comes through Juice.moment: it plays that moment's pixel effect and 8-bit sound on this peer, shakes the camera and holds a short hit stop for this peer's own player, and fires the moment on twoDKit.events.

twoDKit.Sprite2D calls it from the animation changes it draws (jump, wall jump, land, dash, death) and twoDKit.Player2D from its synced fields and Trapline's events (gem, goal, checkpoint, game over, restart). Both run on every peer, so every player sees and hears every other player's moments (others' sounds quieter, fading with distance) with no network traffic of their own.

MomentEffectSoundOwn player only
jumptake-off dust, stretchjump
wallJumpwall-kick dust, stretchwallJump
landlanding dust and squash; a hard landing (a fall of HARD_LAND_DROP = 5 tiles or more) throws a wide cloud and squashes harderland / landHardsmall shake on a hard landing
dashdash ring, speed lines, flashing after-images, stretch along the dashdashtiny shake
gemcrystal pop burstgem
checkpointgold star fountain at the flagcheckpoint
deathwhite flash on the sprite, pixel burst at the bodydeathcamera shake, ~75 ms hit stop
goalstar fountainlevelClearshake
gameOver / restartgameOver / clicksound only for your own

Sprite2D also kicks up dust when you start running or turn, and scrapes specks off the wall while you wall slide.

API

  • Juice.moment(name, payload) -> payload: play a moment and fire it. payload: player, x, y (feet), isLocal, face (1 / -1), plus the moment's own fields.
  • Juice.squash(kind, t, strength?) -> dw, dh: squash and stretch in whole, even art pixels at t seconds into jump, land, hardLand, wallJump, dash or dashUp (Juice.SQUASH holds the shapes). Sprite2D draws it with Sprites.setSquash, which resamples the frame at art-pixel resolution, so it stays crisp.
  • Juice.landing(drop) -> kind, strength: "land" or "hardLand" for a fall of drop tiles.
  • Juice.shakeCamera(amount), Juice.freeze(seconds): this peer's camera shake (tiles) and hit stop (the engine's time scale, held briefly on this peer only).
  • Settings on this peer: Juice.enabled, Juice.shake (multiplier), Juice.hitstop (seconds), Juice.HARD_LAND_DROP. Per sprite: Sprite2D.effects, Sprite2D.squash. Sounds: Player2D.sfxVolume, Player2D.sound, or twoDKit.sfx.
local Juice = require("twoDKit.juice")
Juice.shake = 0.5      -- gentler screen shake
Juice.hitstop = 0      -- no freeze on death