Workshop › Connect Four › Step 15 of 38
Whose turn?
What we are doing
At the top, a message says whose turn it is: Red's turn or Yellow's turn.
```js
ctx.fillStyle = 'white'
ctx.font = 'bold 18px sans-serif'
ctx.textAlign = 'center'
let message = turn === 1 ? "Red's turn" : "Yellow's turn"
ctx.fillText(message, canvas.width / 2, 26)
```
What it means
font sets the letters, textAlign = 'center' makes x the middle of the text, fillText(text, x, y) paints it.
message is chosen with ? :. The texts use double quotes because they contain a single quote.
Your turn
At the end of draw, after the loops, leave an empty line and write the five lines.
Skills: Drawing on a canvas
← The next disc Playing with the keyboard →
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