logo
By Lawrence

5 minutes

From Cannon to Chute

A cannon fires the same ball the same way every time. A mining chute should scatter its rocks a little, and scatter them the same way on every run.

A cone, and a seed

Each launch is tilted by a random amount, up to spread radians off the chute's direction: a cone. The random numbers come from a generator that starts from a seed in the scene's data, so the same seed gives the same stream. Our chute's numbers:

spread 0.012 rad            the widest tilt is 0.6875°
55 units, muzzle to x = 27  up to 0.66 units off the line
seed 24301, first 24 shots  tilts from 0.079° to 0.679°, mean 0.428°

With gravity switched off, the first 16 rocks cross x = 27 within 0.83 units of each other, 16 px on a 16:9 window 1000 px tall. A replayable stream is one where a hole placed once keeps working.

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