Workshop › Puzzle Bobble-style Bubble Shooter › Step 18 of 31
The heart of the game: when the new bubble makes a group of three or more of its color, the whole group pops, 10 points each.
```js
let score
score = 0
function remove(cells, points) {
for (const [r, c] of cells) {
grid[r][c] = -1
score += points
}
}
// Three or more of one color, touching: they pop.
const group = connected([[r, c]], (nr, nc) => grid[nr][nc] === color)
if (group.length >= 3) {
remove(group, 10)
}
```remove empties a list of cells (-1) and adds points for each.attach, connected starts at the new bubble and spreads only through its own color.let shot, write let score; in reset, under shot = null, write score = 0.connected, write remove.attach, write the comment and the group lines under grid[r][c] = color.Skills: Collision detection
← Flood fill Bubbles that fall →