Workshop › Typing Rain › Step 3 of 33
A word on the canvas
What we are doing
Text is drawn like a rectangle: set the pen (font, alignment, color), then fillText. We write one word, rocket.
```js
const FONT = 'bold 20px monospace'
ctx.font = FONT
ctx.textAlign = 'left'
ctx.fillStyle = '#cbd5e1'
ctx.fillText('rocket', 40, 120)
```
What it means
FONT is the words' font: bold, 20 pixels, monospace (every letter equally wide).
textAlign = 'left' puts the start of the text at x.
fillText(text, x, y) paints the text; y is its baseline, the line the letters sit on.
Your turn
- Under
GROUND write FONT.
- At the very end, leave an empty line and write the four text lines.
Skills: Drawing on a canvas
← The ground A function that draws →
All steps
- A sky for the words
- The ground
- A word on the canvas
- A function that draws
- A list of words
- Make them fall
- The game loop
- A new word from the list
- Let it rain
- Gone past the ground
- Lock on to a word
- Listen to the keyboard
- Letter by letter
- Half a word in yellow
- Let go of a lost word
- Lives
- Hearts
- Score
- Out of lives
- Freeze the game
- The game over panel
- Play again
- Levels
- Faster and faster
- Best score
- Accuracy
- Words per minute
- Your speed at the end
- Where the keys go
- Draw the keyboard
- Light up the next key
- Tap the keys
- Build it yourself: change your mind