Learn by Building Workshop Skills GitHub Türkçe Workshop › Mario-style Platformer › Step 36 of 37
Reach the flag What we are doing Touching the pole wins the level: one overlap check and one more state, 'won'. The end screen already appears for any
state that is not 'playing'; it only needs the right words.
```js
if (overlaps(player, flag)) state = 'won'
ctx.fillText(state === 'won' ? 'Level complete!' : 'Game Over', canvas.width / 2, 160)
```What it means
After the pit check, touching the pole sets state = 'won'; update stops, the end screen shows.
The big text is Level complete! when won, Game Over otherwise. Space starts a new game in both cases.
Your turn
In update, under the pit check, write the flag line.
In draw, change 'Game Over' in the end screen to the conditional.
Skills: Game states
← The flag Build it yourself: jump buffering →
All steps The sky A level made of text Draw the tiles What is solid? Is a box touching anything? Find the start Draw the player Gravity Landing on tiles Which keys are held? Speed up Friction Walls Jump Bump your head Short hops A few frames of grace Coyote time A camera that follows Stop at the ends Draw only what is on screen Coins Collect them Count, and screen versus world Enemies Enemies that walk Do not walk off ledges Lives and a fresh start Falling into a pit Enemies hurt Stomp! Squashed enemies are gone Game over Play again The flag Reach the flag Build it yourself: jump buffering