Dungeon

Hey folks,

This is a game I started a long time ago but haven’t posted until now. It’s finally gotten to the point where it’s too big to work on so I’m just going to release it as is. I present: DUNGEON

Some features:

  1. 100% written in blocks
  2. Procedurally generated dungeons (different every time)
  3. Over 90 tilemaps!

Hope you enjoy it! There isn’t really a “game over” screen, but there is an end. If you get to a really big room then you’ve beaten it.

p.s. This project is so big that most computers have a hard time opening it in blocks. Be warned that you might hang your browser if you try to import it. Also, I apologize for the code. I got pretty lazy towards the end :smile:

37 Likes

Wow. That was shockingly fun to play. Great job!

3 Likes

@richard
It was a really fun game! Just I couldn’t load it onto my Brainpad Arcade, when I did I waited at least an hour but it just didn’t load. But really fun game!

2 Likes

太棒了,可以用作教科书!

2 Likes

@Icicles I haven’t tested it on the brainpad, it might not work. It does work on the pybadge/pygamer (or at least did work)

2 Likes

Hello! This is Dmitry, from TinkerGen STEM Education. Our company made a retro gaming console for use with Makecode Arcade, called GameGo. We have also developed a series of free online courses to help our users to get started with GameGo and learn how to make their own video games. Despite the courses are written for GameGo, there is no restriction on use with other hardware or purely in Makecode simulator.
In the course, there is a recommendation section, where we recommend some good games for students to help them learn. We want to include Dungeon, a game, that you made, in recommendation section. We think it is very suitable as Demo Game for GameGo, because it fully demonstrates the characteristics of Arcade.

We hope to obtain your permission to allow us to recommend your game in the course, and use Dungeon as Demo Game in GameGo. In addition, we will send you a free GameGo for you to use and create even more wonderful games. Please reach me at maslovdmitry@chaihuo.org for further communication!
@richard

4 Likes

dude see the new update of the amazing maze if you can thanks send me an email if you like

2 Likes

OMG!! this is amazing.
I love this, congrats!

2 Likes

Niceeeeeee

3 Likes

man ive been playing a lot and i think i keep going in circles

4 Likes

welp i am really lucky
394th try: 20 seconds

2 Likes

Ummmm @richard


Is this suposed to happen?

3 Likes

nope!

3 Likes

avoiding spikes wow this is a fun ga- noclips into backrooms


UHH

1 Like

not again

4 Likes

Hey sorry for reviving this I’m just super curious how you stored and read the data for each of the individual rooms in a dungeon and their connections. I’ve dabbled in procedural generation but I still have no idea how your system is so simple!
Other questions
How is the overall dungeon layout generated randomly?
and how do you generate consistent dungeons but with the right amount of variation?
How do you find the right dungeon tilemaps to connect to each one?
Would something like this be possible without using multiple tilemaps?
How did you store and read player changes to a dungeon room after they have left?

1 Like

@Luke

How is the overall dungeon layout generated randomly?

the overall dungeon layout isn’t actually randomly generated, i made four by hand and just randomly choose from this list (spoilers):

the layout might not be random, but the rooms that make up the dungeon are randomly connected to make each dungeon unique.

now if i wanted to make a random layout for a dungeon, i’d use an algorithm to create a maze that i’d use as a template.

how do you generate consistent dungeons but with the right amount of variation?

by cheating (see above)

How do you find the right dungeon tilemaps to connect to each one?

the dungeon layout is authored as an image, like this:

image

the green pixel marks the entrance and the red pixel marks the exit, and every pink pixel is a room in the dungeon. each pink room in the dungeon can have between one and four doors, depending on how many other rooms are bordering it. since there are four directions a door can be in (north, east, south, and west), that means there are 15 different combinations of doors that a room can have! here is a table that lists them all (an X means there is a door in that direction):

id north east south west
1 X
2 X
3 X
4 X
5 X X
6 X X
7 X X
8 X X
9 X X
10 X X
11 X X X
12 X X X
13 X X X
14 X X X
15 X X X X

so, for each pixel in the image I figure out the correct room type based on how many pixels border it. you can see the code for this in the getRoomType function.

for each of these room types, I hand wrote six possible tilemaps that can be loaded for that combination of doors. you can see all of these tilemaps inside of the setTilemap function, which takes two arguments: the room type (a number between 1-15 from the above table) and the room index (a number between 0-5 which represents the version of the room to load).

when this game generates a dungeon it loops over the layout image and for each pixel figures out the correct room type and a random room index and stores them in a double array of numbers. all of this logic is inside the loadDungeon function.

you might also see a variable called roomIndices in that function, that’s an array that keeps track of the last index used for each possible room type. whenever a new room is generated, we increment that number for the room type so that we aren’t just loading the same room over and over again.

Would something like this be possible without using multiple tilemaps?

sure! i would keep the logic pretty much the same and just “draw” each tilemap onto one giant tilemap as the world is generated. that’s pretty easy to do (see the tile util extension for blocks that let you set/get the tiles from a tilemap in a variable).

however, that strategy would only work because each of the tilemaps in this game are the same size and always place doors in the same place. if you wanted to do more varied rooms, you’d have to figure out how to draw “hallways” between the rooms which would probably be really annoying. I know we did this on stream at some point…

How did you store and read player changes to a dungeon room after they have left?

I keep a double array that marks each of the rooms that they player has visited. then you can just check it by doing visited[col][row]. there isn’t much state to this game, either a room has been cleared or it hasn’t. it’s impossible to leave a room that isn’t cleared (the doors are locked), so keeping track of visits was all i had to do.

for more complicated state, you can simply modify the tilemap when you enter and leave a room. as long as you keep a reference to that tilemap (e.g. in a variable, an array, or using the connections blocks in the tile-util extension), when you reload that tilemap using the same reference then the changes will persist.

5 Likes

Wow this is super helpful thank you!!

1 Like

@Luke I just remembered that we did a stream like four years ago where I recreated all of this code:

5 Likes

I know its alot to ask but is there a easier way to do this “map of tilemaps” by using the tile-util or tilemaps extensions?