Workshop › Tetris-style Blocks › Step 20 of 32
If a new piece does not even fit where it appears, the pile has reached the top: the game is over. A state variable
remembers it, and the loop stops dropping.
```js
let state // 'playing' or 'over'
state = 'playing'
if (!fits(piece.shape, piece.x, piece.y)) state = 'over'
if (state === 'playing' && time - lastDrop >= 800) {
```newGame sets state to 'playing'.spawn checks the new piece: if it does not fit where it appears, the game is 'over'.let lastDrop = 0 write let state.newGame, under the board = ... line, write state = 'playing'.spawn, at the end, write the fits check.loop, add state === 'playing' && to the if.Skills: Game states
← One function starts a game Game Over on screen →