Workshop › Candy Crush-style Match 3 › Step 19 of 29
Falling is a drawing trick: the board changes at once, but each gem remembers in drop[r][c] how many pixels above its
new place it came from, and is drawn that much higher.
```js
let drop // drop[row][col]: how many pixels above its place a gem is still drawn
drop = board.map((row) => row.map(() => 0))
board[write][c] = board[r][c]
drop[write][c] = (write - r) * SIZE
write--
}
for (let r = write; r >= 0; r--) {
board[r][c] = randomGem()
drop[r][c] = (write + 1) * SIZE
}
ctx.arc(x + SIZE / 2, y + SIZE / 2 - drop[r][c], SIZE / 2 - 6, 0, Math.PI * 2)
```board.map((row) => row.map(() => 0)) makes a grid the size of the board, full of 0.r down to row write fell write - r rows: that many SIZEs.write + 1 rows higher than their places.draw subtracts drop[r][c] from the gem's y.let matched write let drop.reset, at the end, write the drop = ... line.collapse, write the two drop[...] lines as shown (put braces around the new-gems loop).draw, subtract drop[r][c] in the ctx.arc(...) line.Skills: Game states, Arrays and objects