Workshop › Rhythm Lanes › Step 12 of 35
When you press a lane it should light up for a moment. Each lane gets a countdown in lit: while it is above 0, the
lane is drawn lighter, and every frame counts it down by one.
```js
let lit // frames each lane stays lit after a press
lit = [0, 0, 0, 0]
lit = lit.map((n) => Math.max(0, n - 1))
ctx.fillStyle = lit[lane] > 0 ? '#334155' : '#1e293b'
```lit has one countdown per lane; reset sets all four to 0.lit.map(...) makes a new list with 1 taken off each number, but never below 0 (Math.max picks the bigger).condition ? a : b picks a when the condition is true: a lit lane is #334155, a dark one #1e293b.let frame write let lit.reset, write lit = [0, 0, 0, 0].update, above frame += 1, write the lit.map line.draw, in the lanes loop, change the '#1e293b' color line as shown.Skills: Game states
← The game loop Keys for the lanes →