Workshop › OutRun-style Racer › Step 12 of 44
Everything in draw is worked out from position. Make position a little bigger every frame and the segments slide
towards you: the road moves. How much bigger is the speed. update does this, and wraps back to the start at the end
of the track: the track is a loop.
```js
let speed
speed = 0
function update() {
position += speed
if (position >= trackLength) position -= trackLength
}
```speed is how many units we move per frame; reset sets it to 0.position += speed adds the speed to the position.trackLength brings the camera back near the start.let position write let speed.reset, under position = 0, write speed = 0.reset, above the // Perspective comment, write update, followed by an empty line.Skills: Game states, Velocity and gravity
← Striped grass Which keys are down? →