Gravity Defied

Ruby · DragonRuby · WebAssembly

Gravity Defied,
rebuilt in Ruby.

The 2004 J2ME motorbike trial, reimplemented with DragonRuby. Same physics, all 30 original tracks, running right here in your browser.

Keyboard game: arrows or WASD. Best on a desktop browser.

Autopilot on Pro · Undertaker · 0:10.22. Found by beam search, replayed frame for frame.

Technical highlights

The divider above is the real Intro track, drawn from the game's level data.

Plain Ruby on DragonRuby

A 60 fps tick in Ruby. The same code runs natively and, compiled engine and all, as WebAssembly on this page.

16.16 fixed-point physics

Integer math with C-style int32 wrap-around and truncating division. No floats in the simulation, so every run is deterministic.

Six masses, ten springs

Wheels, frame and rider are point masses joined by damped springs, integrated with adaptive sub-steps against the track polyline.

Bit-for-bit tests

8,200 steps recorded from the reference TypeScript port are compared value by value. Any drift in any coordinate fails the build.

Beam-search autopilot

Clean runs are found offline by beam search over held inputs, then replayed frame for frame in the game. Press D in the menu.

Controls

↑ ↓
Gas, brake
← →
Lean back, lean forward
R
Restart the track
G
Original sprites or line art
D
Watch the autopilot (menu)
Esc
Back to the menu

Tracks and bikes unlock as in the original: finish a track to open the next one. Best times are saved in your browser.

Play in browser