Map Generator 2
Behold! An extremely simple Rougelike map generator. You can find the C# source code and compiled executable here.
It’s rather simple: the class called map contains a public method called build that will randomly build a map; there is a public two dimensional array called gameMap that contains the map; and to reset a public method called resetmap which resets the map.
The map building process can be summarised as follows:
- Build a single room in the centre of the map.
- Pick a random point on the map adjacent to closed cell.
- Decide upon a new feature to build.
- See if there is room to add the new feature.
- Yes – go to step 5.
- No – go back to step 2.
- Add the feature. If the feature is a room increment the room counter.
- Go back to step 3, until the room counter exceeds the maximum number of rooms required.
The form’s property grid contains 7 properties that are used in the generation of the map: their names are self evident, and changing them will change the characteristics of the final map.Obviously, this produces a primitive looking map: chaotic and sprawling, but it’s a nice effect and looks like the sort of thing a crazed horde of goblins would actually build…..