Workshop › Puzzle Bobble-style Bubble Shooter › Step 19 of 31
Popped bubbles should not just vanish. Each one jumps up a little and falls off the screen, pulled by gravity.
```js
let falling // popped and dropped bubbles on their way out: { x, y, vy, r, color }
falling = []
const p = cellPos(r, c)
falling.push({ x: p.x, y: p.y, vy: -2, r: R, color: grid[r][c] })
for (const f of falling) {
f.vy += 0.4
f.y += f.vy
}
falling = falling.filter((f) => f.y - f.r < canvas.height)
for (const f of falling) drawBubble(f.x, f.y, f.color, f.r)
```falling, moving up (vy: -2).vy, so it slows, turns and falls faster and faster.let shot, write let falling; in reset, under shot = null, write falling = [].remove, write the two lines at the top of the loop.update, write the gravity loop and the filter line.draw, under the grid loop, draw the falling bubbles.Skills: Velocity and gravity
← Three in a row pop Cut them loose →