Workshop › Simon Says Colors › Step 14 of 27
A for loop cannot show the sequence: it would run through it in a single frame. Instead showAt remembers which step
comes next, and timer spreads the steps over many frames. After the last step, it is the player's turn.
```js
let showAt // which step of the sequence is being shown, and when
showAt = 0
if (showAt === sequence.length) {
state = 'input'
return
}
// Light the next pad, then wait a little longer than it stays lit, so repeats are two separate flashes.
light(sequence[showAt], 30)
showAt += 1
timer = 30 + 8
```showAt is the step of the sequence to show next; nextRound starts it at 0.showAt === sequence.length), it is the player's turn.sequence[showAt], move on to the next step, and wait 38 frames.let state, write let showAt.nextRound, write showAt = 0 under state = 'showing'.update, replace light(sequence[0], 30) and state = 'input' with the new lines.Skills: Game states, The game loop
← The computer shows a pad Watch, then your turn →