Workshop › Simon Says Colors › Step 13 of 27

The computer shows a pad

What we are doing

The game has two phases: the computer is 'showing' the sequence, or it waits for the player's 'input'. After a short pause (timer), the computer lights the first pad for 30 frames and hands the turn to the player.

```js
let state // 'showing' or 'input'
let timer

  state = 'showing'
  timer = 40 // a short pause before the sequence is shown

  if (state !== 'showing') return
  timer -= 1
  if (timer > 0) return
  light(sequence[0], 30)
  state = 'input'
```

What it means

Your turn

  1. Under let sequence, write let state and let timer.
  2. In nextRound, under push, set state and timer.
  3. At the end of update, under the litFor block, write the five new lines.

Skills: Game states, The game loop

All steps

  1. Get the canvas and the pen
  2. A dark board
  3. The first pad
  4. Two colors for every pad
  5. All four pads
  6. A function that draws
  7. Light a pad
  8. Draw again and again
  9. The sequence to remember
  10. Show the round
  11. Light a pad for a while
  12. Go dark again
  13. The computer shows a pad
  14. Show the whole sequence
  15. Watch, then your turn
  16. Check each press
  17. Play with the keyboard
  18. Which pad is at a point?
  19. Play with the mouse
  20. Progress and mistakes
  21. A function for a new game
  22. Click to retry
  23. Light up when pressed
  24. Faster and faster
  25. Save the best score
  26. Show the best score
  27. Build it yourself: no dawdling