logo
By Lawrence

5 minutes

Count Down, Then Count Rocks

The director already keeps a tally. Left alone, First Bend fails at 16.55 s with every miss off the field, and starts again 2.8 s later. It also pays 100 points for each delivery on score.add, and nothing in the scene listens.

Count down, then four ways to finish

Every level counts down first, 3, 2, 1, GO, with the field laid out and the holes free to move. Only then does the chute open, and only rocks fired after GO count. The count needs a little slack, because floating point never lands on zero:

// 3 s counted down in 180 frames of 1/60 s leaves 5.7e-15, not 0
Math.ceil(5.7e-15)          // 1: the "1" would hang on for one more frame
countdownNumber(5.7e-15)    // 0: GO, on time

From GO, a rock is in play from the moment the chute fires it until one of four endings. The plant takes it: delivered. It touches a solid mass or falls into a hole: crashed or swallowed. It leaves the field: escaped. Or it is still flying after maxFlightSeconds, 16 by default: expired. The last one exists because some rocks never finish on their own. A rock in a stable orbit goes round forever.

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