Sunday, June 5, 2011

Terrain Generation using Midpoint Displacement

Well it's been a productive couple of days since my last post. I've been busy working on implementing a better random terrain generator for my game using some tiles that I made myself using Paint.net. I must say that I have never been a strong algorithmic programmer, but I have been reading up on the subject and from what I have found, an easier way to implement random terrain is to use the Midpoint Displacement Algorithm.

This algorithm repeatedly uses two points in space and places a midpoint between them. Then, one point on either side of the midpoint is created at a random height (or displacement) from the midpoint. This algorithm recursively calls itself and continues to create a rough terrain shape. The more times this is done, the smoother the effect.

I'm definitely not the expert on this subject, so if you would like to read more about it check out this post. In the meantime, here is a sample the results of my terrain generation code. Note that there is still much work to be done to clean it up and improve it. This is definitely the first time I've done this.

That's all for now...

No comments:

Post a Comment