Workshop › OutRun-style Racer › Step 22 of 44
Driving off the road should cost you. On the grass (playerX below -1 or above 1) a car faster than a third of the top
speed loses another 2.5 every frame.
```js
else speed -= 0.4
const offRoad = Math.abs(playerX) > 1
if (offRoad && speed > MAX_SPEED / 3) speed -= 2.5 // grass slows you down
```Math.abs drops the sign (Math.abs(-1.5) is 1.5), so one question covers both sides of the road.&& means "and": off the road and faster than a third of the top speed.In update, under else speed -= 0.4, write the two grass lines.
Skills: Velocity and gravity
← No turning on the spot Steering by touch →