Whatever you draw becomes solid, anything round becomes a wheel with a motor in it, and your drawing has to cross hills, steps and wobbly planks to reach a flag. Good drawings get there. Bad drawings are funnier. The hard part is turning a wobbly finger stroke into shapes a physics engine can simulate.
A physics engine wants neat convex shapes, and a finger makes wobbly loops that overshoot and never quite close. So each stroke is first resampled, so a fast hand and a slow hand give the same points. If the ends nearly meet, or the stroke crosses itself, the loop is kept and the tails are cut off. Then Ramer-Douglas-Peucker keeps only the corners that matter: a wobbly circle of sixty-odd points becomes a dozen or so.
02 · How it works
Deciding what each shape is
The biggest shape becomes a body. A smaller, compact shape touching a body becomes a wheel, a small shape inside a body becomes a window, and an open line becomes a stick. Hollow outlines are cut into convex pieces of at most eight corners, falling back to the hull if the cut loses area. Touching pieces are welded into one rigid group, and pieces touching nothing fall off. The whole drawing is then scaled to between 2.6 and 5.2 metres.
03 · How it works
Making almost anything drivable
Each wheel gets a sprung axle and a motor. Motor strength is a share of the machine's own weight, so a heavy doodle is not weaker than a light one, and every wheel aims for the same road speed whatever its size. A little traction control eases the motor when the body rears up, and the motors ease off in the air so jumps do not end in a backflip. None of this saves a bad idea. It only makes the failure entertaining.
04 · How it works
What is real physics
The rigid bodies, joints, friction and collisions are planck.js, a JavaScript port of Box2D, stepped at a fixed 60 times a second. Nearly round wheels roll as true circles and lumpy ones keep their lumps, which is why square wheels work, slowly. Each course is a short recipe of hills, steps and seesaws, and the tests drive every course from start to flag with four different doodles, so a physics change cannot quietly make one impossible.
05 · How it works
Ink that looks drawn
The world is one 2D canvas, drawn in metres. Every ink line is traced twice with a slightly different wobble, and the two are swapped seven times a second, which is what makes them look hand-drawn. Every sound is an oscillator or a burst of noise built with WebAudio at the moment it is needed, so there are no audio files. The share picture is drawn on a canvas in the browser, and nothing is uploaded.
06 · What it teaches
The idea underneath
Doodle Drive shows how much work sits between a human gesture and a simulation. A physics engine only understands convex shapes, joints and motors, so a drawing has to be cleaned, sorted, cut and welded first. It also shows why wheel shape, wheel size and balance matter: a tall tower tips over, and small wheels struggle on stairs.
How it works, in one picture
How Doodle Drive works
Your drawing → Clean up → Sort the shapes → Motors → The drive. Open the picture to read it at full size.
1600 × 1000 · JPEG
Questions about Doodle Drive
01
How does Doodle Drive decide what is a wheel?
Any smaller, compact shape that touches the body becomes a wheel with its own motor and sprung axle. You can tap a shape to flip it between body and wheel, and a small shape drawn inside the body becomes a window.
02
Do square wheels work in Doodle Drive?
Yes, slowly. Nearly round wheels are simulated as true circles, but lumpy shapes keep their lumps, so a square wheel bumps along on its corners. The physics engine treats it like any other solid shape.
03
Which physics engine does Doodle Drive use?
It uses planck.js, a JavaScript port of Box2D, stepped at a fixed 60 times a second, with poly-decomp-es for cutting shapes into convex pieces. The traction control and size limits on top are game design.
In numbers
Courses10A go10 to 30 sScript67 kB
Poster
Doodle Drive poster
Doodle Drive on one sheet: a screen from it, its name and what it is. Free to use in pieces about the project, with a credit to Pratyush Shivam.