Platformer — live coded
Inspired by Bret Victor's Inventing on Principle (2012) · see also worrydream.com.
A 2D platformer whose entire logic lives in the editor below.
Edit JUMP-V, GRAVITY, platforms, or
step itself — it takes effect next frame without
resetting the player. Drag the timeline to rewind; while
rewound, a faint yellow arc shows the predicted replay
from that point using your recorded keypresses. Now edit
a constant — the arc redraws to show what would have happened
with the new value. Hold Alt (or Ctrl) and drag any
number in the source for a live scrubber.
←/A + →/D move · ↑/W/Space jump · R respawn
timeline
live
What's happening
(defonce state ...)creates the world state atom exactly once. Re-evaluating the source doesn't touch it.(defonce history ...)is a bounded vector of past states — one per frame, last 300. The scrubber reads this to rewind.(defn predict ...)runsstepforward 45 times from whatever the current display state is, returning[x1 y1 x2 y2 ...]. The JS draws those as dots. Becausestepis pure and reads liveJUMP-V/GRAVITY, editing a constant redraws the dots instantly.- Every user-facing behavior — physics, gameplay, history, prediction — is Clojure data flowing through a pure function. No hidden state, no hot-reload magic.