Fox Studios logo Fox StudiosGame projects, devlogs and Scratch builds
Projects

Building a Top Down Dungeon Crawler in Scratch

Most people who try to build a dungeon crawler in Scratch get stuck at the same point: the player walks through walls, the enemies stack on top of each other, and the project slows to a crawl by room three.

A laptop on a desk showing a colorful pixel art dungeon game with a small hero, slimes and a locked door on screen

Most people who try to build a dungeon crawler in Scratch get stuck at the same point: the player walks through walls, the enemies stack on top of each other, and the project slows to a crawl by room three. We hit every one of those problems on our own build, a small top down game called Lantern Keep, and this is the honest record of how we got it working.

It took us five weekends, about 22 hours in total, and the finished project has six rooms, three enemy types, keys, doors and a boss. Nothing here needs extensions or hacked blocks. It is all standard Scratch 3.

Why we picked a dungeon crawler in Scratch

After our endless runner, we wanted a project that forced us to learn state. A runner barely remembers anything. A dungeon has to know which rooms you cleared, which doors are open, how many keys you hold and how much health you have left. That is exactly the kind of bookkeeping that teaches you to structure a bigger project, and it is why the genre makes a great third or fourth build. We explain how we choose projects like this in how we pick what to build next.

We also set a strict scope before writing a single block. Six rooms. Three enemies. One weapon. No inventory screen. If you have read why your first game should be tiny, you know why we cut the list down that hard.

Room system and walls

One sprite, many costumes

Our first attempt used a separate backdrop for every room and drew walls as part of the art. Collision used the "touching color" block against the wall color. It worked for about an hour, until our artist added a slightly different shade of gray to one room and the player walked straight through it.

We switched to a dedicated Walls sprite with one costume per room. The costume is the collision map: solid shapes where you cannot walk, transparent everywhere else. The visible art lives on the backdrop. Collision checks use "touching Walls?" which never cares what color anything is.

Moving without sticking

Wall sliding is what makes top down movement feel good. We move on the x axis first, check for a wall, and step back if touching. Then we do the same for the y axis separately. Splitting the axes means if you hold up and right into a wall on the right, you still slide upward along it instead of freezing. Player speed is 3 pixels per frame, which feels right on the 480 by 360 stage.

Changing rooms

When the player touches the edge of the stage, we broadcast "next room" with a direction stored in a variable. Every sprite listens, the Walls sprite switches costume, enemies for the old room delete themselves, and the player reappears 20 pixels in from the opposite side. A list called RoomCleared keeps six entries of 0 or 1, so cleared rooms stay empty when you come back.

Enemies with clones

Each enemy type is one sprite that spawns clones when a room loads. A list called RoomEnemies holds strings like "slime,slime,bat" for each room, and a small loop splits the text and creates the right clones at preset positions.

The three behaviors are deliberately simple:

  • Slime. Moves toward the player at 1 pixel per frame, then pauses for half a second. The pause makes it fair.
  • Bat. Flies in a random direction, bounces off walls, ignores the player. Annoying in the right way.
  • Archer. Stays still, turns to face the player, and fires an arrow clone every 2 seconds.

Scratch caps a project at 300 clones at a time. We never got close, but arrows were the risk. Every arrow clone deletes itself when it touches a wall or leaves the stage, and that one rule kept our clone count under 25 in the busiest room.

To stop slimes from piling on top of each other, each clone checks "touching Slime?" and, if true, nudges 2 pixels away in a random direction. It is crude. It also works.

The advice we stopped following

Plenty of Scratch tutorials tell you to put all your game logic in one big "forever" loop on the player sprite, so everything stays in one place and runs in a predictable order. We tried it. By week two that loop had more than 140 blocks and nobody on the team wanted to touch it.

The bigger problem was timing. When one loop handles movement, attacks, damage and room changes, a single "wait" block for an attack animation freezes everything else. The player stopped moving every time they swung the sword.

What worked instead was small scripts that talk through broadcasts and shared variables. Movement lives in one script. Attacking lives in another. Taking damage is triggered by a "player hit" broadcast with its own short invincibility timer of 1 second. Each script is short enough to read on one screen. Order problems did show up, and we solved them by having a single "game tick" broadcast from the stage that every sprite responds to, instead of scattered forever loops. That gave us predictable order without one giant script.

Keys, doors and the boss room

Keys are a sprite that only appears when the last enemy in a room is gone. Picking one up adds 1 to a Keys variable. Locked doors are another costume on the Walls sprite. When the player touches the door with at least one key, we subtract a key, switch to the open costume and set that room's door flag in a list.

The boss is a large slime with 12 health. At 6 health it splits into two small slimes using clones, then keeps chasing. Players told us this was the best moment in the game, and it cost about forty blocks.

Performance and what we would change

By room four the project ran noticeably slower in the browser on a school Chromebook. Three fixes brought it back to a steady frame rate:

  1. We replaced "touching color" checks everywhere with sprite touching checks, which are cheaper.
  2. We turned on "run without screen refresh" for custom blocks that only do math, such as distance calculations.
  3. We shrank our backdrops from detailed bitmaps to simpler vector art.

If we started again, we would plan the lists for room data on paper first. Half our bugs came from rooms being numbered 0 to 5 in one list and 1 to 6 in another. Scratch lists start at 1. Pick that and stick to it.

Lantern Keep is the project we now point new members to when they ask what to build after their first game.

Frequently asked questions

How do you make walls in a Scratch top down game?

Use a separate wall sprite whose costume matches the solid areas of each room, and check "touching Walls?" after every move. Move on the x and y axes separately so the player slides along walls instead of sticking. This is more reliable than checking for a wall color.

How many clones can a Scratch project have?

Scratch allows up to 300 clones at once across the whole project. Projectiles are usually what push you toward the limit. Make every bullet or arrow clone delete itself when it hits something or leaves the stage.

Is Scratch good for making an RPG or dungeon game?

Yes, for small ones. Lists and broadcasts handle rooms, keys and enemy data well. Large maps and many enemies on screen can slow down, so keep the scope tight and simplify art and collision checks.

DF
Diego Fenn

Diego covers finished builds and the community around them, and runs the feedback threads that shape what the studio makes next.

More posts by Diego

More in Projects

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp gamevui123 gleasongrade greetingsday hacklabasu haskell iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven strcoding tetapatrium topselller uneplanteartificielle vipertechcr webtech1223411 wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto