The Rube Goldberg Sandbox — Hand-Rolled Rigid Body Physics
Drop physics objects. Build chain reactions. Dominoes, balls, ramps, hinges, ropes, fans. Custom SAT collision + impulse response, no Box2D. Hand-drawn sketch aesthetic.
What this is
A 2D physics sandbox in pure JS — no Box2D, no Matter.js, no external library. Custom rigid body engine with SAT (Separating Axis Theorem) for polygon collision, analytical circle/polygon and circle/ circle, impulse-based response with friction + restitution, position- based dynamics for stable stacks. 6 solver iterations + 2 substeps/ frame + Baumgarte stabilization. Hand-drawn sketch aesthetic with paper texture background. Drag-and-drop palette: circles, rectangles, ramps, beams, hinges, ropes, dominoes, bumpers, fans, pegs. Edit mode to draw walls and place shapes; hit BUILD to run the simulation. Two-click hinge or rope lets you connect shapes. 8 puzzle levels: Sandbox, Drop the Ball, Ring the Bell, Domino Cascade, Pendulum Smash, Seesaw Flip, Wind Tunnel, Target Practice.
Why this is mind-blowing
Crayon Physics won the Independent Games Festival in 2008. Box2D is a 50,000-line library. Both are here in 1884 lines from one paragraph. The custom physics engine alone is what would take a junior dev a semester to write.
2D physics sandbox in the spirit of Rube Goldberg / Crayon Physics.
Real Box2D-style rigid body simulation in pure JS (no library). Drag-
and-drop physics shapes from a palette. Press play, watch chain
reactions. Pre-loaded puzzles ("get the ball to the bell") with par-
piece scoring. Sandbox mode for unrestricted building.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Hand-rolling rigid body physics (SAT polygon collision + analytical circle/poly + impulse-based response with friction + restitution) in 1884 lines proves you don't need a library to do real physics.
- 6 solver iterations + 2 substeps/frame + Baumgarte stabilization (percent=0.2, slop=0.5) is the standard recipe for stable stacks. The model knows the magic numbers.
- Contact-point picker: select only vertices that lie INSIDE the other polygon (with edge-edge fallback) — the bug in the naive implementation is using AABB vertices on huge static walls. The fix is the lesson.