Workshop › Candy Crush-style Match 3 › Step 24 of 29
hasMove also gives a hint. idleFor counts the idle frames; after 300 (five seconds) the hint is a possible move.
Making a move clears it.
```js
let idleFor // frames since the last move
let hint // a possible move, shown after five idle seconds
function reset() {
// ...
idleFor = 0
hint = null
}
function trySwap(a, b) {
// ...
chain = 0
idleFor = 0
hint = null
startClearing()
function update() {
// ...
if (phase === 'falling') {
// ...
return
}
idleFor += 1
if (idleFor === 300) hint = hasMove()
}
```reset and every move set idleFor to 0 and hint to null.'falling' block now ends with return, so the lines after it only run while the game is idle.let drop write let idleFor and let hint.reset, at the end, and in trySwap, under chain = 0, write idleFor = 0 and hint = null.update, write return at the end of the 'falling' block, and the two idleFor lines at the end of the function.Skills: Game states, The game loop