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.
WallsDungeon Floor tiles. They are solid. Name the object Wall.
Key and DoorKey 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.
TextA Text called Locked saying The door is locked. Find the key! Untick Visible when the level starts.
SoundsPower up for the key, Door for the door.
NutHouse
Dungeon Key being played: the hero, ghosts, gems and the door
Dungeon Key is this recipe with ghosts and gems added.

Build it

  1. Set Gravity pulls to Off (everything floats). A maze is seen from above, so nothing falls.
  2. Tick Snap to grid. Lay Wall tiles to make corridors. Alt-drag a tile to copy it quickly.
  3. Put the Key far from the start, and the Door across the exit corridor.
  4. Events tab โ†’ + New event โ†’ Hero โ†’ Collides with another object โ†’ Key. Do Destroy Key, Add to the counter Keys 1, play Power up.
  5. + New event โ†’ Hero โ†’ Is overlapping another object โ†’ Door. + andโ€ฆ โ†’ Keys โ†’ Compare counter = equal to 0.
  6. In the Hero cell do Stop, then Set position: X โˆ’6, Y 0, Measured from Hero. That nudges the hero back. Then Show Locked.
  7. + New event โ†’ Hero โ†’ Collides with another object โ†’ Door. + andโ€ฆ โ†’ Keys โ†’ Compare counter > more than 0.
  8. Do Change animation on the Door โ†’ open, Hide Locked, play Door, then Next level.
  9. 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.

Still stuck?

Try the Chocobreak tutorial, open a sample game and read its rules, or look at the questions people ask.