A maze with keys and doors
By the end you will have a top-down maze, a key that fills a counter, and a door that blocks the way until you have one.
What you need
The Counter and Is overlapping another object are Advanced. Switch to Advanced mode.
| Hero | + Add object โ Library โ Hero (top-down). It walks in four directions. |
|---|---|
| Walls | Dungeon Floor tiles. They are solid. Name the object Wall. |
| Key and Door | Key and Door from the library. The Door has a closed and an open animation. |
| Counter | + Add object โ New โ Counter. Starts at 0, Label in front Keys: . Name it Keys. |
| Text | A Text called Locked saying The door is locked. Find the key! Untick Visible when the level starts. |
| Sounds | Power up for the key, Door for the door. |

Build it
- Set Gravity pulls to Off (everything floats). A maze is seen from above, so nothing falls.
- Tick Snap to grid. Lay Wall tiles to make corridors. Alt-drag a tile to copy it quickly.
- Put the Key far from the start, and the Door across the exit corridor.
- Events tab โ + New event โ Hero โ Collides with another object โ Key. Do Destroy Key, Add to the counter Keys 1, play Power up.
- + New event โ Hero โ Is overlapping another object โ Door. + andโฆ โ Keys โ Compare counter = equal to 0.
- In the Hero cell do Stop, then Set position: X โ6, Y 0, Measured from Hero. That nudges the hero back. Then Show Locked.
- + New event โ Hero โ Collides with another object โ Door. + andโฆ โ Keys โ Compare counter > more than 0.
- Do Change animation on the Door โ open, Hide Locked, play Door, then Next level.
- Press โถ Play level. Walk into the door first. Then fetch the key and try again.
WhenHero collides with Key
DoDestroy KeyAdd 1 to KeysPlay sound Power up
WhenHero is overlapping DoorKeys = 0
DoStop HeroSet position of Hero to (โ6, 0) from HeroShow Locked
WhenHero collides with DoorKeys > 0
DoMake Door play โopenโHide LockedPlay sound DoorNext level
The blocking rule uses Is overlapping, not Collides with. Overlapping is checked all the time, so the door keeps pushing the hero back.
Make it yours
- Two doors, two keys: the second door needs Keys โฅ at least 2.
- Spend the key: add Subtract from the counter 1 to the opening rule.
- Ghosts: add Ghost with Chases another object โ Hero, Only when closer than 170.