Workshop › Pac-Man-style Maze Chase › Step 29 of 42
Right now the ghosts start hunting before you have even found the keyboard. A state fixes that: 'ready' after the
actors are placed, 'playing' once you steer. update does nothing unless the state is 'playing'.
```js
let state // 'ready', 'playing' or 'over'
state = 'ready'
function steer(dir) {
state = 'playing'
function update() {
if (state !== 'playing') return
```placeActors sets 'ready': at the start, and later after every lost life and every new level.update freezes everything else, including the clock.let level write let state ...; at the end of placeActors write state = 'ready'.steer write state = 'playing'; at the top of update write the guard.Skills: Game states
← Cyan works with red Tell the player to start →