Workshop › Whack-a-Mole › Step 17 of 18
Each popup is drawn as a yellow "+1" that rises 30 pixels and fades out over its 600 ms.
```js
ctx.fillStyle = '#fef08a'
ctx.font = 'bold 24px sans-serif'
ctx.textAlign = 'center'
for (const p of popups) {
const t = (now - p.born) / 600 // 0 → 1 over the popup's life
ctx.globalAlpha = 1 - t
ctx.fillText('+1', p.x, p.y - t * 30)
}
ctx.globalAlpha = 1
```t goes from 0 when the popup is born to 1 when it dies.globalAlpha is how see-through everything drawn next is: 1 − t fades it out.p.y - t * 30 moves it up by up to 30 pixels.globalAlpha = 1 afterwards, so the rest of the picture is drawn solid again.In draw, between the holes loop and the white score text, write the popup lines.
Skills: Drawing on a canvas
← Remember each hit Build it yourself: combos →