Tuesday, March 4, 2014

Zity - Road Beginnings

After my work on the inventory I decided to take a break and go back to the generation of the island. I knew all the steps I had in mind for generating roads and cities so it didn't take too long to start implementing them.

First thing first, I needed a way of drawing highways over the island to connect high centers of population (cities). Well in order to get that far I needed to have population data to sample from. So using the good old Perlin Noise library I came up with a noise map that was spaced out and smooth enough to represent centers of population. I then overlay this onto the map for visual purposes.

 (Areas in black - high population, white - low population)

From this map I could now construct roads by starting at a random point on land and projecting the road in a direction. Then for each additional road segment I simply search for the best direction for a road to go within the area in front of it by looking at the highest population density. This method produces roads that tend to circle around and pass through black (high population) areas of the map.

(Red lines are roads, duh)
While this can provide some nice looking highways, I find that they tend towards the dark areas too much and I'll most likely be implementing a weighted value approach that's too complicated to explain in this blog. Also as of now I still have to scale the island up to it's final size. Currently the map is only 300 pixels wide by 200 pixels tall and each pixel will represent a tile (25 x 25 picture) in the game world. Since I want the world to be realistically big it will have to be around 400,000 tiles long which, for those of you following along, is also 400,000 pixels long. An image that long would be ridiculous and my generating methods would not work on data that big so instead I'll be scaling the generated island to the correct size before moving on to the roads and buildings.
I digress, The roads function fairly nicely and are tweakable easily so I'm prepared to move on to other things, namely streets and local roads. I'll admit I'm not too confident in any plan for streets and lots yet but you've got to try to get anywhere in programming. Number one piece of advice I've ever received was to make it work until it doesn't, and then fix it. This wouldn't make sense in a business application but in independent game development you cannot wait around til everything is extensible and moddable, you have to make it work and quickly.


No comments:

Post a Comment