Home > Roguelike > Map Generator 2

Map Generator 2

Behold! An extremely simple Rougelike map generator. You can find the C# source code and compiled executable here.

map1.png

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:

  1. Build a single room in the centre of the map.
  2. Pick a random point on the map adjacent to closed cell.
  3. Decide upon a new feature to build.
  4. See if there is room to add the new feature.
    1. Yes – go to step 5.
    2. No – go back to step 2.
  5. Add the feature. If the feature is a room increment the room counter.
  6. 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…..

Categories: Roguelike Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.