Workshop › Asteroids › Step 9 of 41
Real space has no friction, but a game is nicer with a little: every frame both velocity parts are multiplied by 0.99, so a ship left alone slowly drifts to a stop.
```js
const FRICTION = 0.99
ship.vx *= FRICTION
ship.vy *= FRICTION
```*= multiplies: each frame the velocity keeps 99% of itself. After 60 frames about 55% is left.THRUST write FRICTION.update, above ship.x += ship.vx, write the two friction lines.Skills: Velocity and gravity
← Thrust and drift A speed limit →