Workshop › Whack-a-Mole › Step 5 of 18
Each hole remembers until when its mole stays up: upUntil, a time. The mole is up while now has not reached it.
A mole is drawn as a lighter brown circle inside its hole.
```js
holes.push({ x: col * CELL + CELL / 2, y: TOP + row * CELL + CELL / 2, upUntil: 0 })
function isUp(hole) {
return now < hole.upUntil
}
if (isUp(hole)) {
ctx.fillStyle = '#92400e'
ctx.beginPath()
ctx.arc(hole.x, hole.y, 32, 0, Math.PI * 2)
ctx.fill()
}
```upUntil: 0 means no mole: time is always past 0.isUp answers true while the current time is before upUntil.upUntil: 0 to the object in holes.push.let now, write isUp.draw, inside the holes loop, write the mole block under ctx.fill().Skills: Game states
← A clock and a loop Moles pop up →