Workshop › Space Invaders-style › Step 7 of 21
Holding Space should not fire a stream of bullets. After a shot, the next one can only come 350 milliseconds later.
We keep the time of each frame in now and the time of the last shot in lastShot.
```js
const COOLDOWN = 350 // milliseconds between shots
let lastShot = -COOLDOWN
let now = 0
if (now - lastShot < COOLDOWN) return
lastShot = now
function loop(time) {
now = time
```loop receives the time from the browser and keeps it in now.lastShot starts at -350, so the very first shot is allowed at once.BULLET_SPEED, write COOLDOWN; under bullets, write lastShot and now.shoot, write the two cooldown lines.loop the time parameter and keep it in now.Skills: Game states, The game loop