Workshop › Pinball › Step 33 of 42
The balls left are written at the top right. When the game is over, a dark box in the middle says so.
```js
ctx.textAlign = 'right'
ctx.fillText('Balls ' + balls, 330, 50)
ctx.textAlign = 'center'
if (state === 'over') {
ctx.fillStyle = 'rgba(12, 10, 9, 0.85)'
ctx.fillRect(60, 330, 280, 80)
ctx.fillStyle = 'white'
ctx.font = 'bold 22px sans-serif'
ctx.fillText('Game over', 200, 364)
ctx.font = '15px sans-serif'
ctx.fillText('Space to play again', 200, 392)
}
```textAlign = 'right' makes the text end at the given x, so Balls lines up with the right side of the table.textAlign = 'center' centres the texts that follow on x = 200.rgba(12, 10, 9, 0.85) is the table's color with 85% opacity: a box you can faintly see through.In draw, under the Score line, write the lines shown.
Skills: Drawing on a canvas