A markdown file on your PC
2D platformer: Celeste-grade movement
Use this when building any 2D side-view platformer. A plain build almost always works but feels stiff or floaty.
Constants
Gravity 900, MaxFall 160, JumpSpeed −105, VarJumpTime 0.2, JumpGraceTime 0.1, JumpBufferTime 0.08, HalfGravThreshold 40, …
Jump
if (onGround) p.jumpGrace = C.JumpGraceTime;
else if (p.jumpGrace > 0) p.jumpGrace -= dt;
if (p.varJumpTimer > 0) p.varJumpTimer -= dt; Pitfalls
grounded = vel.y === 0is true at the apex of every jump.- Variable dt physics changes the jump height with the frame rate.
- A camera locked to the player is nauseating on every jump.
Camera
Celeste’s camera eases toward its target with a framerate-independent lerp, plus a forward focus of about 24px in the facing direction.
Wall jump
Allowed when a solid is within 3px to that side, not only when touching. Holding into the wall can’t cancel the kick for 0.16s.
Tests to write
- approach() never overshoots, in both directions.
- A held jump rises higher than a tapped jump.
- Pressing jump up to 0.1s after walking off a ledge still jumps.