Game Development Community

Random maps

by John Coyne · 06/24/2008 (5:42 am) · 4 comments

I thought I'd take a break from bubble choo choo's and try a spot of 3d. The results are the beginnings of a random urban map generator, here is a screen:

www.thewilderzone.co.uk/random/screenone.jpg
Obviously my next task will be to put little houses in most of the blank concrete parts.

#1
06/24/2008 (8:57 am)
looks cool; how's it work ?
#2
06/24/2008 (9:42 am)
It uses 3d tiles pulled from a 2d array (not really a 2d array, but its the best way to explain it).

The most important part is a recursive method, it takes upper and lower x/y variables which it uses to manipulate the entire array or just parts of it, it goes something like this:


1. find the center of the whole map
2. add/delete a small random variable from this, so we are randomly off center
3. from this off center position, draw north, south, east and west roads, splitting the map into 4 (if you were to stop at this point, it would look a bit like an English flag). If the road intersects with another road, stop.
4. take each of the 4 map pieces, and send them back into this recursive method

At the beginning of the method I check the width and height of the sub-map and exit if its below a certain number.

Once this is done its just a matter of iterating through it and placing the relevant 3d model in the correct space.
#3
06/24/2008 (12:30 pm)
I know there's probably countless resources out there on the logic of how these work; but going out there and doing it yourself really helps sharpen your skills. Good luck with this side-venture =)
#4
06/24/2008 (2:45 pm)
Thanks Brian. :O)