Workshop › Angry Birds-style Slingshot › Step 41 of 47
next() starts over when the game is over. Space launches while aiming and calls next() otherwise; a tap on the
canvas after the end does the same.
```js
function next() {
if (state === 'won' || state === 'lost') reset()
}
else if (event.key === ' ') state === 'aiming' ? launch() : next()
canvas.addEventListener('pointerdown', (event) => {
if (state === 'won' || state === 'lost') return next()
```next does something only when the game is over.? : can also choose between two actions: launch while aiming, otherwise next().return next() in the pointer listener calls next and stops there.keydown listener write next.pointerdown listener, write the new first line.Skills: Keyboard and mouse input, Game states
← The end panel Three levels of data →