Learn by Building Workshop Skills GitHub Türkçe Workshop › Pac-Man-style Maze Chase › Step 40 of 42
Harder levels What we are doing Every level should be a little harder: the ghosts get faster (but never faster than the player's 8 frames a tile),
and power pellets last a second less each level, down to two seconds.
```js
return Math.max(8, 10 - level)
scaredFor = Math.max(120, 420 - 60 * (level - 1))
```What it means
Math.max(a, b) is the bigger of the two: it works as a floor. 10 - level drops with the level, but never below
The fright lasts 420 frames on level 1, 360 on level 2, ... and never less than 120.
Your turn
In ghostFrames, replace return 9.
In frighten, replace scaredFor = 420.
Skills: Game states
← Blue, then flashing A best score that lasts →
All steps The maze as text The game loop Draw the walls A set of pellets Draw the pellets The player Where can you walk? What a mover remembers One frame of movement Move every frame Turns you can press early Glide between tiles Turn back at once Swipes on a phone Eat the pellets Show the score Clear the maze A red ghost A ghost never turns back The ghost walks The ghost hunts you Four ghosts in the house One by one out of the house Scatter or chase? Every ghost to its corner Pink cuts you off Orange is shy Cyan works with red Wait for the first key Tell the player to start Three lives Caught! Game over Play again Frighten the ghosts Power pellets work Scared ghosts wander slowly Eat a scared ghost Blue, then flashing Harder levels A best score that lasts Build it yourself: the slow tunnel