Workshop › Mario-style Platformer › Step 22 of 37
The o characters are coins. Tiles stay in the level forever, but coins disappear when collected, so loadLevel copies
each one out of the text into an object in coins. They are drawn as yellow circles, in the world.
```js
let coins
coins = []
if (line[col] === 'o') coins.push({ x: x + 8, y: y + 8, w: 16, h: 16, taken: false })
ctx.fillStyle = '#facc15'
for (const coin of coins) {
if (coin.taken) continue
ctx.beginPath()
ctx.arc(coin.x + coin.w / 2, coin.y + coin.h / 2, 8, 0, Math.PI * 2)
ctx.fill()
}
```taken: false.coins = [] at the start of loadLevel empties the list before filling it.beginPath starts a shape; arc(cx, cy, r, 0, Math.PI * 2) is a full circle of radius r around (cx, cy); fill
paints it.continue. The coins are drawn before restore, so they scroll with the world.let player write let coins.loadLevel, write coins = [] first, and the 'o' line under the 'P' line.draw, above ctx.fillStyle = '#dc2626', write the coin drawing and an empty line.Skills: Arrays and objects, Drawing on a canvas
← Draw only what is on screen Collect them →