Workshop › Mario-style Platformer › Step 12 of 37
When no direction is held, the speed should bleed away: each frame it keeps only 80% of itself. Tiny speeds are snapped to exactly 0, or the player would drift forever by fractions of a pixel.
```js
const FRICTION = 0.8
else player.vx *= FRICTION
if (Math.abs(player.vx) < 0.05) player.vx = 0
```else runs when no direction is held: vx *= 0.8 keeps 80% of the speed.Math.abs is the size of a number without its sign; under 0.05 either way, the speed becomes exactly 0.MAX_SPEED write FRICTION.updatePlayer, write the else line under the if (input !== 0) line.Math.abs line under the clamp line.Skills: Velocity and gravity