Random Dungeon Generation in Alienoid CoreHere is just the basic process I use to generate the dungeons.
Here are some maps it generated, they are a lot more spread out than the ones used in the game but still a good example of what it does (A better example would be the map on the debug screen a few posts back).First I decide on the dimensions of the map I want to make in tiles and then create a 2D array to hold the map info. This map will be filled with true and false vales, with true being the floor and false being empty space in the end.
Second I randomly put down a bunch of rectangles within a certain size range. If a rectangle is placed so that it intersects another rectangle, it is scraped and a new rectangle is created. This process continues until a predetermined number of rectangles are on the map. All these rectangles are filled with the true value or floor.
Third I go through the rectangles again and draw a line of floor from the centre of every rectangle to the centre of the next one on the list. This connects all the rectangles so they aren't a bunch of separate floating islands.
Lastly I place floors randomly in all the empty spaces and then use cellular automata to smooth the floor into a round shape without too many small clumps or protrusions floating out in the middle of nowhere. A good tutorial on making caves with cellular automata is
here. Really, Cellular automata is what makes the level look all smooth and natural, I think it's a great tool for level generation.
The level generation process in the game is not done, there are still many things for me to do, like using the flood fill algorithm to make sure all parts of the map are accessible to the player, before it's complete.
Sorry for the huge text dump with no pictures or diagrams, hope you can understand it because I wrote it up really quick. I'll try and add in some pictures outlining the process and expand on it with specifics later.