Workshop › Pac-Man-style Maze Chase › Step 35 of 42
The power pellets turn the hunters into the hunted. frighten sets a timer (scaredFor, 7 seconds), resets chain
(what the next eaten ghost is worth) and makes every ghost that is out scared. Each scared ghost also turns around
at once: a clear sign that something changed.
```js
let scaredFor // frames the ghosts stay scared
let chain // points for the next ghost eaten
ghosts = GHOSTS.map((g, i) => ({ ...g, col: 8 + (i % 3), row: 9, dir: STOP, progress: 0, frames: 10, waiting: g.delay, scared: false }))
scaredFor = 0
function frighten() {
scaredFor = 420
chain = 200
for (const g of ghosts) {
if (g.waiting > 0) continue
g.scared = true
turnAround(g)
}
}
```turnAround is the same function that lets the player reverse mid-step.let clock write the two variables.placeActors, add scared: false to the ghosts and write scaredFor = 0 under clock = 0.caught, write frighten.Skills: Game states
← Play again Power pellets work →