Workshop › Pool › Step 11 of 33
The felt slows the balls: every frame each ball keeps 98.5% of its speed. Multiplying by the same number every frame slows it smoothly, fast at first and gently at the end. Below a tiny speed it is set to exactly zero.
```js
const FRICTION = 0.985 // speed kept each frame
for (const b of balls) {
b.vx *= FRICTION
b.vy *= FRICTION
if (Math.hypot(b.vx, b.vy) < 0.05) b.vx = b.vy = 0
}
```vx *= FRICTION multiplies the speed by 0.985 each frame, keeping the direction.Math.hypot(vx, vy) is the ball's real speed, the length of the velocity (Pythagoras).b.vx = b.vy = 0 sets both to zero in one line.COLORS write FRICTION.update, under step(), write the loop.Skills: Velocity and gravity