Workshop › Lunar Lander › Step 15 of 31
The engine is under the lander and always pushes the way the lander points. Upright it pushes straight up; tilted,
part of the push goes sideways. sin and cos split the push into its two parts.
```js
const THRUST = 0.1 // speed gained per frame of engine, along the direction the lander points
function burning() {
return state === 'flying' && keys.ArrowUp
}
if (burning()) {
// The engine pushes along the direction the lander points: angle 0 is straight up.
lander.vx += Math.sin(lander.angle) * THRUST
lander.vy -= Math.cos(lander.angle) * THRUST
}
```burning() is true while flying with the up arrow held.sin is the sideways part and cos the upward part of a push of 1.vy -= because up is a smaller y.const SPIN write the THRUST constant.function touchdown() {, write burning, followed by an empty line.update, under the two arrow lines, write the if (burning()) block.Skills: Velocity and gravity