Workshop › Asteroids › Step 8 of 41
Up is thrust: it does not set the speed, it adds a little velocity in the direction the ship faces. Then the ship moves by its velocity every frame. It keeps drifting the way it was going, even after you turn: that is inertia.
```js
const THRUST = 0.12
if (keys.ArrowUp) {
ship.vx += Math.cos(ship.angle) * THRUST
ship.vy += Math.sin(ship.angle) * THRUST
}
ship.x += ship.vx
ship.y += ship.vy
```(cos, sin) times THRUST is added to the velocity.TURN write THRUST.update, under the two turning lines, write the thrust block and the two moving lines.Skills: Velocity and gravity, Keyboard and mouse input
← The game loop A little friction →