Workshop › Pool › Step 9 of 33
A shot gives the cue ball a velocity: a speed, power, in the direction aim. The same cos and sin split it into
the two parts the position needs, vx and vy. Space shoots.
```js
let power
power = 8
function shoot() {
cue.vx = Math.cos(aim) * power
cue.vy = Math.sin(aim) * power
}
else if (event.key === ' ') shoot()
```power is 8 at the start: 8 pixels per frame.vx and vy are the parts of the speed along x and y. At aim = 0 the shot is vx = 8, vy = 0.let aim ... write let power; in reset, under aim = 0, write power = 8.reset, leave an empty line and write shoot.else return.Skills: Velocity and gravity