logo
By Lawrence

5 minutes

Pump the Hole

The hole's mass and its horizon are two numbers in the file, set by hand to agree. We want the mass on the mouse wheel, and the horizon to follow it.

A horizon in proportion to the mass

Schwarzschild's radius, r = 2M/c², grows in step with the mass. With this game's c of 30.15, that is the mass times 0.0022, BlackHole's horizonScale:

mass 450     horizon 0.99
mass 900     horizon 1.98     twice the mass, twice the horizon
mass 1500    horizon 3.30     the wheel stops here

The physics takes a new horizon at once, and only the picture eases. Each frame the drawn radius closes 1 − e^(−3·dt/τ) of the gap, a fraction built from that frame's own dt, so every frame rate draws the same curve. A fixed fraction per frame does not:

0.99 toward 3.3, τ = 0.25 s, after 1/6 s       30 fps    60 fps    144 fps
1 − e^(−3·dt/τ) of the gap each frame          2.9874    2.9874    2.9874
a fixed fifth of the gap each frame            2.5431    3.0520    3.2891

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