Generating maps on Basternae 2 was a bit of a pain. It was done with about 1000 lines of hacked-together C code that I wrote that read in an ASCII file, asked you the dimensions and map type (surface, underdark, etc), and then brute-forced it into a simple zone file. It was not elegant, but it worked, usually. Unless, of course, you entered a wrong number, had an extra character on one line, or anything like that.
The surface map I showed yesterday is just an enlarged 120 x 50 bitmap. I only used 9 colors when creating it — one for each terrain type. There is no accompanying ASCII text file.
It’s entirely possible with a lot of grunting and swearing that I could convert it into an ASCII file which I could then import into that old C program. Why bother? There has to be a better way. Turns out there is.
Last night I created a small application that does one thing and only one thing — generates maps for Basternae.
Here’s how it works:
1. Load in a bitmap of any size.
2. Select a menu item and the program analyzes the bitmap and generates a list of all the different colors used in it.
3. Use that list to generate a room template for each color — title, description, and terrain type.
4. Let the user edit the list of templates so you can say light green is “The Forest of Evil” and dark green is “Drachenwald Forest”.
5. Select another menu item to have the program use the template file as it goes through the image pixel by pixel and generates a room for each pixel.
The obligatory screenshot:
I’m a bit surprised that it only took a couple hours to write. It’s the sort of thing that the serialization, bitmap, list, and datagrid classes built into .NET make very easy to do.
It is missing one major thing — it doesn’t connect the rooms together via exits yet. That will be easy enough to add (probably about an hour to do). It does, however, generate a zone that loads into the editor and can be tweaked and refined further.
There’s also one neat thing about the design — the room templates can be saved off to a file and loaded again, so you don’t have to edit it all in one sitting, risk losing your work if the power goes out, and can use the same room definitions with different image variations (provided you used the same colors).