Zelda with random dungeons!

Show off your games, demos and other (playable) creations.
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Zelda with random dungeons!

Post by Imaculata »

What started out as a simple question about random dungeon creation, has now turned into a full blown Zelda game. However, I should note that this is not the final goal. All the Zelda graphics are placeholders, and will eventually be replaced by completely different graphics, with a very different art style.

So what is this thing?
I wanted to make a Zelda clone, but with endless random dungeons, and far more cool stuff than the original game. What I have so far is a game that creates a random maze of rooms, each room with a random lay out, and random treasures.

Random maze generation
I'm still working out the finer points of the system, but currently here is how it works. The game starts by choosing a random maximum width and height for the level, and then places the entrance randomly. The door through which you enter always faces away from the edge of the level. It then starts creating a random corridor, crawling through the level room by room, until it reaches its limit, and then it places the exit room. It also turns the second to last room into a boss room, and seals it with a boss door.

It then starts picking random empty rooms that are part of the main chain, and uses them to create side-tunnels. When it reaches the end of a tunnel, it tries to place a random treasure there. Treasures are determined randomly at the start of the game. But each dungeon will always contain: 1 boss key, 1 map, 1 compass, 1 crystal ball, 1 random weapon, relic or legendary item, and a random number of keys.

It also creates a couple of random bonus rooms, which may contain chests filled with money. At the end of the creation process, it places traps, buttons, and picks random room templates for each empty room. Rooms can also have variations, so not every entrance has to look the same. But this is merely a matter of adding more room files for the game to choose from. Currently I'm fine with 1 version for each room.

Image
Image link

So lets go through the features that I've implemented so far.

Treasure chests
Chests spawn randomly throughout the dungeon, and if a chest contains a special weapon, a treasure room is created with a big chest. Upon using the chest, it opens, and the item is given to the player. None of the items have been implemented yet, but they do have a visual representation upon acquiring them. Different music is played depending on the kind of item.

Image
Image link

Keys and locked doors
When ever the game places a key in a room, it tries to find a suitable place for a matching door. The rules for this are simple. When ever the game makes side corridors, it remembers the depth at which it started the new tunnel (this is called the origin). So it knows that the door must:

1> Be placed in a different chain, in a room with a higher depth. Because first you find the key, and then you encounter the door.
2> Or, in the same chain, but a higher depth.

It also gives priority to rooms that are considered 'special'. Any room that contains a special item, the boss key, or is the room outside the boss room, is considered a special room. So those are checked first, and you'll often find them locked with color-coded doors.

Right now there are 6 keys. The boss key, which only fits on the boss door. The red, green, blue and yellow key, which fit their respective doors. And lastly, the skeleton key, which fits any color door (but not the boss door).

Keys you've collected are currently shown at the top right of the screen.

Image
Image link

Buttons and switches
Switches are among the random objects that the dungeon can place in a room. Their positions are predefined, but the game has several spots to choose from. Switches toggle the blocks up or down that come out of the floor. They can also be toggled with ranged attacks, and by traps.

Buttons are similarly randomly placed, and can reveal hidden chests, or open a trapdoor.

Dungeon items, map, compass, crystal ball
The dungeon items always spawn in any dungeon, and they are all working. The map instantly reveals all the rooms in the dungeon on your mini map, but not their connections. The compass shows a yellow dot where the exit is on your mini map(this is how the compass worked in Zelda 1). The crystal ball reveals secret rooms, and plays a warning signal when you enter a room that contains a chest (hidden or otherwise). In combination with the map this is even better, because the crystal ball also highlights rooms that you have not visited yet, if you have a map. The red dot on the map is the player. Currently the mini map is working perfectly, and I'm very happy with it.

Image
Image link

Trapdoors
Trapdoors are placed randomly, and can be triggered to open when certain conditions are met. This varies, but sometimes you need to press a button (shown in the picture), push a block, find a hidden switch, or kill all the enemies. These last three have not been implemented yet.

Image
Image link

Traps
This took a lot of work to implement, but it is now working perfectly. During dungeon-creation, the game places a random number of traps in the dungeon (more for bigger dungeons). The locations for pressure plates are predefined, but the game randomly picks one of the possible locations (usually near doors). It then searches for shooter-locations, that are in a direct line with the pressure plate. Shooters are invisible, but can fire a variety of projectiles at the player from the wall. These projectiles can also destroy vases, and toggle switches. These projectiles can be blocked with the shield, and can harm enemies too (once I implement them).

Vases
Vases can currently be destroyed by hitting them with the sword. They do not drop anything yet, and cannot be picked up and thrown yet (but I will add this feature eventually). As with a lot of other objects, vases come in sets that are predefined, but the game chooses randomly which locations to use, -and IF it wants to place them.

Health display
The game currently has a working health display, that can show half-hearts, quarter-hearts and empty hearts, as well as full ones. It also starts beeping if you are down to 1 heart.

Getting hurt
The player flashes red if he gets hurt.


What are the challenges up ahead?
The next big thing I want to implement, is additional room types. Currently the game places single rooms, but I'd like to have rooms that stretch over multiple screens. This means that the game has to match up multiple rooms. I'd also like to fine tune the algorithm, and get some more interesting dungeons. Maybe height differences, and warp zones would be cool to have. Pushing blocks, and picking up items would also be nice. And of course effects, and items that drop, which you can then collect. I'll be looking at these things next.

There's some other room types that haven't been implemented yet. I'd like the game to also place very specific types of rooms, such as hubs, single corridors, and long hallways.
User avatar
Drakkahn
Prole
Posts: 28
Joined: Sat Jan 17, 2015 11:09 pm

Re: Zelda with random dungeons!

Post by Drakkahn »

This is really cool! I would love to see where this goes.
Sind
Prole
Posts: 10
Joined: Mon Mar 31, 2014 4:40 pm

Re: Zelda with random dungeons!

Post by Sind »

This does look interesting, but it's really hard to say anything concrete if you don't give us a playable demo or somesuch =/
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Zelda with random dungeons!

Post by Imaculata »

Its a bit early for a playable demo. There's not really any game play yet. No functional weapons (apart from the sword), you can't die, and there are no enemies yet. But I figured I would still show the progress, because the project was progressing pretty quickly, and it would be nice to show off none the less.
Codex NG
Prole
Posts: 5
Joined: Sun Sep 06, 2015 2:20 am

Re: Zelda with random dungeons!

Post by Codex NG »

I released a Pixel Map Editor, hopefully it will be approved soon, its very basic, maybe you can use it with your game to edit the maps
and keep the file size small if its not small enough :)

I also have a Pixel Map loader but I haven't released that yet.
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Zelda with random dungeons!

Post by Imaculata »

I'm currently using Tiled to create the room templates. But it's a bit cumbersome. Because my game only requires the table data, and not all of the other fluff that Tiled files add to it. Plus the formatting in Tiled is wrong, and requires me to add brackets to every line by hand. Tiled also has the annoying habit of increasing the tile-numbers when you use multiple tilesheets.

My Zelda game uses three layers at the moment: Background, foreground, and a map info layer. The info layer uses a very small tile sheet, and includes all the information regarding spawn locations for various room entities. But because I also use a very large tilesheet for the background and foreground, Tiled continues counting from the last tilesheet. So what should be a table with numbers from 1 to 20, is turned into a table from 300 to 320. So this forces me to delete the other layers and save the mapinfo separately to get the correct numbers. And even then I have to add all those brackets by hand.

So a tool that has the same functionality as Tiled, but does a better job at saving the data in the right format, would be most welcome.
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Zelda with random dungeons!

Post by Imaculata »

A quick update.

Background animations
I've fixed all the problems that I had before with background animations, and the performance has even improved a bit as well.

Bow and ladder
I've implemented the bow and the ladder. The bow fires arrows very quickly, and the more you spam those arrows, the more inaccurate your shots get. I'm still planning to add a charged shot as well.

The ladder allows you to cross water and lava of one tile in diameter. But right now it only works if you align with a tile correctly. I want the ladder to also work if you are in between two tiles. So I'm going to have to come up with a better solution for this.

Jumping
Whenever there is a height difference, you can now jump down to a lower level by running into the ledge. These jump spots have to be defined along with the room, but it looks smooth. I will later be adding the drop-room type, so I can have shortcuts in the level where you jump down to a previous section.
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Zelda with random dungeons!

Post by Imaculata »

Image
Image link

Drop rooms

A new room type has been added, called drop rooms, which use the new jump mechanic. Drop rooms are rooms with a height difference, that function as a one-way short cut. They spawn at the end of chains, if there is an adjacent room to link to, and if that room is not part of a chain that has a higher origin that the one that the drop room is linking from. This is to prevent a situation in which a player drops down into a series of rooms, and runs into locked doors for which he does not have the keys yet. So you won't see them in large numbers, but there usually is one drop room in at least 1 out of 2 dungeons.

Image

Image link

Rivers

This is a variation of the drop room, which uses the same placement parameters, but is even more rare. Rivers require a ladder, or the flippers to cross. If it happens to be a lava river, then only the red flippers or the ladder can cross it (and not the normal flippers). River rooms spawn 1 our of 4 times, when ever a location for a drop room is found. The game does not pay any attention to whether you have the required item to cross it, since this is not a required room connection to reach the exit.

Image
Image link

Hallways

Hallways are also kind of rare. The game looks for any consecutive 3 rooms that are connected in a straight line, either horizontally or vertically. If these rooms are part of the same chain, and do not contain any special doors, or any special rooms already, then this room type can be created. Another requirement, is that horizontal rooms must have an exit door to the west and east on their outer rooms already. And the same goes for vertical rooms: They must already have a door to the north and to the south on their top and bottom rooms. Hallways tend to spawn 1 in 6 times approximately. I'm actually pretty glad to have these in the game now, because sometimes dungeons looked really weird, and were kind of annoying to navigate, when a long row of empty rooms spawned. By giving such configurations their own look, it no longer looks out of place. You can also drop down from the balconies.

For some bizarre reason horizontal hallways are more common than vertical ones. At first I thought this was due to the creation order. So I added randomness to what kind of hall the game checks for first. But this still did not make any difference. Horizontal halls remain more common than vertical ones. And yet there's no difference in the random width or random height of the level. So why does this occur? I have no idea.

I also noticed one occurrence where the top room of a vertical hall blocked off access to couple of rooms in the dungeon. This should never happen, because those room could contain a required item. But I have yet to track down this problem. Its quite possible that I made a tiny mistake in the creation parameters for vertical halls specifically. This could also explain why they are more rare.

Up next

Now that I have multiple rooms that are joined together, I want to reattach the camera to the player, whenever he enters such rooms. Basically, I want the camera to treat these 3 rooms as one big room. I've already added an exception that ensures that the game does not draw doors or doorposts between these rooms. But the camera will need further refinement.
Connorses
Citizen
Posts: 63
Joined: Fri Sep 06, 2013 7:02 am

Re: Zelda with random dungeons!

Post by Connorses »

Welp I'm impressed, I'm always fascinated by random generation. I'll have to review your method for generating levels, it looks very cool but also not needlessly complex.

EDIT: Oh! Oh! Question: Will you be procedurally altering the contents of any room? I imagine you could add some variety by marking a type of tile that gets randomized when a room is created, i.e. there could be a row of blocks with some of them randomly missing, or a few random textures here and there.
User avatar
Imaculata
Party member
Posts: 102
Joined: Mon Aug 10, 2015 2:51 pm

Re: Zelda with random dungeons!

Post by Imaculata »

Connorses wrote: EDIT: Oh! Oh! Question: Will you be procedurally altering the contents of any room? I imagine you could add some variety by marking a type of tile that gets randomized when a room is created, i.e. there could be a row of blocks with some of them randomly missing, or a few random textures here and there.
This is already working. The rooms that you see in the screenshot contain random content. Here's how it works:

For each room type I have a template, but each template can have multiple variations. For example, a dead-end type room could look like a cellar, but also like a storage area, or a prison block. So yes, you could use different sprites or textures for each variation.

Each template also has mapinfo. Mapinfo tells the game where it is allowed to spawn chests, trap-pressure plates, trap-shooters, buttons, teleporters, switchboxes, blocks (movable or stationary) , breakable vases, items, and where the player may jump down.

In the case of the previous screenshot, it looks a little like this:

Image
Image link

So every room that is created will have their chests, blocks, vases and traps in different locations. It is however not entirely random, because otherwise such features could spawn in a location that blocks progression. Besides, you want vases to spawn in clusters, and not completely random. So you may see a breakable vase on either side of the door as you enter, but another room of the same type could not have have vases at all, or have them positioned elsewhere.

In the picture you'll notice a lot of locations for pressure plates (marked in red, called "trap tile") and shooters (marked also in red, called "trap" with an arrow next to it). These are possible locations to spawn these dungeon features. This does not mean that the room will contain a trap, and it will certainly not use up all the locations. If the game decides to place a trap in the room, it picks one pressure plate location out of all the possible locations, and then also uses up any adjacent pressure plate locations too. It then searches for all shooter locations that are lined up with the pressure plate, and randomly picks one.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests