Learn by Building Workshop Skills GitHub Türkçe Workshop › OutRun-style Racer › Step 16 of 44
Your car What we are doing Time for a car. It always sits at the bottom middle of the screen; the road moves under it. A red body and two dark
wheels, painted after the road so they are on top.
```js
// Your car.
ctx.fillStyle = '#ef4444'
ctx.fillRect(W / 2 - 34, H - 44, 68, 30)
ctx.fillStyle = '#111827'
ctx.fillRect(W / 2 - 38, H - 22, 14, 12)
ctx.fillRect(W / 2 + 24, H - 22, 14, 12)
```What it means
The body is 68 by 30, centered (W / 2 - 34), 44 pixels above the bottom.
The wheels are 14 by 12, one on each side, sticking out a little below the body.
Your turn In draw, after the } that closes the second loop, leave an empty line and write the car.
Skills: Drawing on a canvas
← Brake, coast and a top speed Speedometer →
All steps Sky and ground Draw again and again Perspective One piece of road A road made of segments Where we are on the track The road ahead Stripes Paint from far to near Kerbs and a center line Striped grass Moving is one number Which keys are down? The gas pedal Brake, coast and a top speed Your car Speedometer A pedal for phones Move the camera sideways Steering No turning on the spot The grass is slow Steering by touch A track with curves Bend the road No jumps in the curve Which segment am I on? Curves pull you outwards Other cars Distance on a loop Cars that shrink with distance Traffic moves Rear-end crash Counting laps Show the lap A lap timer Show the time Best lap Show the best lap Racing or finished The finish line Finished! Race again Build it yourself: beat the clock