logo
By Lawrence

11 minutes

Oil and Smoke

Everything you fire goes forward. A rammer on your back bumper is safe from your gun, and so is a gunner closing from behind.

This lesson gives the car two rear weapons. Q pours an oil slick on the road behind you. R leaves a cloud of smoke.

Spin from a slick

A car that drives onto oil loses its grip and spins. The game has to answer two questions: which way, and how many times.

Which way depends on where the middle of the slick is. Take an arrow that points straight across the car, out of one door. The dot product, the · below, measures how far the slick's middle sits along that arrow: plus on the side the arrow points to, minus on the other. That sign picks the spin:

across = (cos h, −sin h)          out of one door, for a car with heading h
side   = (slick − car) · across
spin   = sign(side) × 5.5 rad/s

A top view of two cars driving up the page, one each side of a round oil slick. An arrow points out of the same door of each car. For the car whose arrow points at the slick, side is +1.5 and the spin is +5.5. For the other car, side is −1.5 and the spin is −5.5. A curved arrow at each nose bends toward the slick.

Either way, the nose swings toward the slick's middle.

The second answer is once, on the way in. After that one kick the car slides on its old line while the spin winds down, the slide you met in lesson 1.6. In the model, with the car sliding straight, every car ends up turned 123°, about a third of a turn, from any line and at any speed. In the game the driver steers and crashes add spin, so rammers ended between 109° and 136° after one slick.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search