Workshop › Scorched Earth-style Artillery › Step 12 of 23
A tank whose ground was blown away should not float. Each frame, a tank above the ground falls 2 pixels, until it lands on the ground again.
```js
const FALL = 2 // pixels per frame a tank drops when the ground under it is gone
for (const t of tanks) {
if (t.y < groundAt(t.x)) t.y = Math.min(groundAt(t.x), t.y + FALL) // nothing under it: it falls
else t.y = groundAt(t.x)
}
```t.y < groundAt(t.x) means the tank is above the ground (y grows downward).Math.min stops the fall exactly on the ground, not a pixel below.MAX_POWER, write FALL.update, let the tanks fall.Skills: Velocity and gravity