Workshop › Angry Birds-style Slingshot › Step 14 of 47
Pressing Space twice launches two birds. The game needs to know what it is doing: a state of 'aiming' or
'flying'. You can only launch while aiming.
```js
let state // 'aiming' or 'flying'
state = 'aiming'
function launch() {
if (state !== 'aiming') return
...
bodies.push(bird)
state = 'flying'
}
```state holds one of two words.if (state !== 'aiming') return leaves launch at once unless we are aiming. !== means "is not equal to".'flying', so a second Space does nothing.let aim write let state.reset, under aim = ..., write state = 'aiming'.launch, write the if as the first line and state = 'flying' under bodies.push(bird).Skills: Game states
← Land on the ground An empty sling in flight →