Roguelike generation
#1
Posted 19 February 2012 - 01:35 AM
#2
Posted 19 February 2012 - 01:42 AM
A) Pregenerated blocks: Make a bunch of "mini levels" that can be fit together like a jigsaw to form the whole. Perfect for action/roguelikes. Spelunky uses this.
C) Build entire dungeon levels on a textpad and choose them randomly. Lots of work, but good for small levels.
Edited by greep, 19 February 2012 - 01:43 AM.
#3
Posted 19 February 2012 - 01:44 AM
IWell there's three main methods:
A) Pregenerated blocks: Make a bunch of "mini levels" that can be fit together like a jigsaw to form the whole. Perfect for action/roguelikes. Spelunky uses this.Build the level entirely full of walls, then subtract away corridors and rooms with "destroyer" objects. Good for turn-based or diggin (terraria)
C) Build entire dungeon levels on a textpad and choose them randomly. Lots of work, but good for small levels.
I like the sound of A. How do I go about doing that?
#4
Posted 19 February 2012 - 01:49 AM
Then, Divide your "room" into sections with a for loop, like so
122221
233332
233332
233332
233332
122221
As you can see, there are 3 types of "blocks" you will have to make. Corner blocks, side blocks, and center blocks. These have to be designed in such a way that the open spaces in one block will fit into another. Anyways, have to go for a bit like right now, so I'll be more thurough later.
You can also try other methods, but I like this the best.
#5
Posted 19 February 2012 - 02:00 AM
I like the sound of A. How do I go about doing that?
Here's a little something I wrote (and abandoned) quite a while ago. It might be a bit hard to figure out what I'm doing(I was a very sloppy coder back then), but if you poke around you might be able to tell what I've done.
http://www.mediafire.com/?g66xcr3ehrcy0w9
You might get an error because a sound is missing, but that's not important
#6
Posted 19 February 2012 - 02:44 AM
Yes if you could explain more that would be great. I understand what you are saying so far. How big should the room be?First divide your room into several sections, probably 36 or 25 (6 by 6 or 5 by 5)
Then, Divide your "room" into sections with a for loop, like so
122221
233332
233332
233332
233332
122221
As you can see, there are 3 types of "blocks" you will have to make. Corner blocks, side blocks, and center blocks. These have to be designed in such a way that the open spaces in one block will fit into another. Anyways, have to go for a bit like right now, so I'll be more thurough later.
You can also try other methods, but I like this the best.
#7
Posted 19 February 2012 - 08:28 AM
As far as how to actually make the blocks, personally I use a notepad and fill it with letters, which, when loading it from the file, you get them turned into the walls. The notepad would look something like this:
wwEEww
wwEEww
wwEEEE
wwEEEE
wwEEww
wwEEww
Es are empty, ws are walls (actually, personally I just leave E as a space, but it shows up on the forum better here this way). This is a corridor that leaves to the right, an example of a (extremely small) left side block. Character processing is easier in C++ so I actually put it into a C++ program which spits out another textfile that I process in game maker. Kinda silly but it works for me. Anyways you get the idea?
Now if you only want to use 3 types, you will need to rotate the sides and corners, as an upper left corner will not have the same exits as an upper right. To do this, process the file first, giving you a grid in game, then manipulate that grid with code. You'll have to make a dummy grid I think and then base the actual grid to be rotated on that dummy.
You will need about 10-30 of each type mind you, or else the dungeon will not look unique. So seriously consider method B unless you don't mind designing lots of the things.
Edited by greep, 19 February 2012 - 08:31 AM.
#8
Posted 19 February 2012 - 09:47 AM
http://gmc.yoyogames...howtopic=489511
Now, I think I coded that a bit more coplicated than it actually needed to be, mainly because I wanted corridors to link the rooms with spaces between them. Hope that helps!
#9
Posted 19 February 2012 - 10:08 PM
#10
Posted 19 February 2012 - 11:16 PM
#11
Posted 19 February 2012 - 11:40 PM
everybody inspired binding of isaac
Hah... okay I know it's funny that sex has always gotten higher maturity ratings than violence. But ages 16+ because of parodying religion? IN GERMANY?! This... this breaks the record for irony.
Edited by greep, 19 February 2012 - 11:40 PM.
#12
Posted 20 February 2012 - 02:36 AM
I appreciate the explanation, but after reading the options again I like option B.Room size should honestly be as big as you can get without lag if you're an action/rogue. In a turn based roguelike, where you'd be using grids and tiles rather than solid walls, I'd say anything bigger than 150x150 is too big.
As far as how to actually make the blocks, personally I use a notepad and fill it with letters, which, when loading it from the file, you get them turned into the walls. The notepad would look something like this:
wwEEww
wwEEww
wwEEEE
wwEEEE
wwEEww
wwEEww
Es are empty, ws are walls (actually, personally I just leave E as a space, but it shows up on the forum better here this way). This is a corridor that leaves to the right, an example of a (extremely small) left side block. Character processing is easier in C++ so I actually put it into a C++ program which spits out another textfile that I process in game maker. Kinda silly but it works for me. Anyways you get the idea?
Now if you only want to use 3 types, you will need to rotate the sides and corners, as an upper left corner will not have the same exits as an upper right. To do this, process the file first, giving you a grid in game, then manipulate that grid with code. You'll have to make a dummy grid I think and then base the actual grid to be rotated on that dummy.
You will need about 10-30 of each type mind you, or else the dungeon will not look unique. So seriously consider method B unless you don't mind designing lots of the things.
Can you explain a little on that?
#13
Posted 20 February 2012 - 02:45 AM
Well basically, you first fill the entire room with walls, like a for loop. Then you make two random numbers determine to how many corridors and rooms you will make.
Then, starting at the center, you start making corridor_builders. These objects will upon creation will turn walls into empty space from their location out a few blocks in a certain direction. Further corridor builders will choose a random empty space, check if there is too much empty space in the area (i.e. corridor spam, too close to edge of room), and then do the same. Until you run out of corridors.
Then you make rooms. You take a random empty space, move out in one direction, check if it's a wall. If so, good. Move another in the same direction, check if a wall, if so good. Then it will choose a random size and go out in the direction it started, and see if it can make a rectangular room based on if all walls in the (area + 1) are in fact walls and not empty. If so, it creates the room and the door (at the very first wall check), otherwise starts over at choosing a random empty space. Note, the rooms should be highly variable in possible size, like 2x2 to 10x10.
Edited by greep, 20 February 2012 - 02:48 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











