Code and Gravity

About

Code and Gravity makes satisfying ball physics videos with code: ball escapes, plinko, growing balls and guess-the-song games.

How a video is made

Each video starts as a short JSON file that says which simulation to run, the colours, the melody and the seed. A physics engine written in JavaScript runs the simulation 60 times a second. The music and sound effects are synthesised in the browser, and the finished video is rendered frame by frame into an mp4.

Because the same file always gives the same result, everything you watch on YouTube and Instagram can also be played here, with the same ball path.

Explore

Follow

New videos are posted on YouTube and Instagram. Send questions or ideas as a message on either account.