Workshop › Pinball › Step 2 of 42
Draw one wall
What we are doing
The walls of the table are straight lines. We draw the first one: the left wall, from (20, 470) up to (20, 120).
```js
ctx.strokeStyle = '#a8a29e'
ctx.lineWidth = 4
ctx.lineCap = 'round'
ctx.beginPath()
ctx.moveTo(20, 470)
ctx.lineTo(20, 120)
ctx.stroke()
```
What it means
strokeStyle is the line color, lineWidth its thickness, lineCap = 'round' rounds its ends.
beginPath() starts a new shape, moveTo puts the pen down, lineTo draws to a point, stroke() paints the line.
Your turn
Write the seven lines at the very end, under the fillRect line, then press Run.
Skills: Drawing on a canvas
← Paint the table A list of walls →
All steps
- Paint the table
- Draw one wall
- A list of walls
- The game loop
- A ball in the lane
- Draw the ball
- Move by the velocity
- Launch with Space
- Gravity
- Does the ball touch a wall?
- Push the ball out
- Bounce off the wall
- Small steps and a speed limit
- Ready or playing
- The next ball
- Three bumpers
- The ball meets a bumper
- A bumper kicks
- A score and a fresh start
- Points for every hit
- Remember which bumper was hit
- Light it up
- Lit for a moment, points once
- Two flippers
- Where is the tip?
- Flippers stop the ball
- Which keys are held?
- Which way to turn
- Flip!
- A moving wall
- The flipper throws
- Three balls
- Balls left and game over
- Play again
- Remember the best score
- Launch on letting go
- Pull the spring
- Show the spring
- Two thumbs
- Pull with a finger
- Tap to play again
- Build it yourself: slingshots