Workshop › OutRun-style Racer › Step 19 of 44
The car always stays in the middle of the screen, so steering moves the camera sideways and the road moves the other
way. playerX is where we are across the road: 0 the middle, -1 the left edge, 1 the right edge.
```js
let playerX // -1 is the left edge of the road, 1 the right edge
playerX = 0
const near = project(-playerX * ROAD, -CAMERA_HEIGHT, z)
const far = project(-playerX * ROAD, -CAMERA_HEIGHT, z + SEG)
```playerX times ROAD (half the road's width) is how far the camera is from the middle, in world units.-playerX * ROAD to the side of the camera. Nearer segments are wider on screen, so they
shift a lot and far ones hardly at all.let position write let playerX.reset, under position = 0, write playerX = 0.draw, change the first 0 in the near and far lines to -playerX * ROAD.Skills: Game states
← A pedal for phones Steering →