Workshop › Connect Four › Step 34 of 38
Only on your turn
What we are doing
You are red, player 1. Clicks and keys should only drop a disc on your turn, and the waiting disc shows only then, in
red.
```js
if (turn === 1) play(hoverCol)
else if (turn === 1) play(hoverCol)
if (!winner && !falling && turn === 1) disc(hoverCol * CELL + CELL / 2, TOP - CELL / 2, COLORS[1])
```
What it means
- Both the click and the key play only when
turn === 1.
- The waiting disc needs three things: no winner, nothing falling, and your turn. It is always red now.
Your turn
- In
pointerdown, put if (turn === 1) in front of play(hoverCol).
- In
keydown, make it else if (turn === 1) play(hoverCol).
- In
draw, change the waiting disc line as shown.
Skills: Keyboard and mouse input
← The computer's turn You and the computer →
All steps
- A dark background
- A drawing function
- The blue board
- One hole
- A whole row
- All 42 holes
- The board in memory
- Discs in their colors
- Draw every frame
- Where does the disc land?
- Play a column
- Taking turns
- Click to play
- The next disc
- Whose turn?
- Playing with the keyboard
- Keys 1 to 7
- A disc on its way
- Gravity
- Watch it fall
- Inside the board?
- Walking along a line
- Four in a row?
- We have a winner
- Circle the four
- Who won?
- A draw
- Play again
- Try a move and take it back
- Win, or block
- Don't help the player
- Prefer the middle
- The computer's turn
- Only on your turn
- You and the computer
- Counting wins
- Show the score
- Build it yourself: the loser starts