Workshop › Asteroids › Step 20 of 41
The rocks drift too: every frame each one moves by its velocity and wraps around the screen.
```js
for (const asteroid of asteroids) {
asteroid.x = wrap(asteroid.x + asteroid.vx, canvas.width)
asteroid.y = wrap(asteroid.y + asteroid.vy, canvas.height)
}
```In update, under the bullet loop's closing }, write the asteroid loop and an empty line (above the filter line).
Skills: Velocity and gravity
← Jagged rocks When do two circles touch? →