🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Random terrain generation with fixed elevation

Started by
1 comment, last by frob 6 years, 10 months ago

Hi folks, a fellow gamedev here.

 

So recently I've been trying to make a business simulation games (similar to Holiday Island or Sim City), and start moving on the vital element of the game: terrain generation and manipulation. The terrain is a simple heightmap with a randomly generated height values (I haven't implemented the random generation part, cause of this issue I'm talking about). Basically, in my game the terrain has to have fixed elevation, so when you compare a terrain vertex to its neighbors, they could either:

  • have similar height
  • have a 0.5m height difference (higher or lower). It must not have more than 0.5m difference.

I need to do that to simplify the terrain manipulation (the game kinda heavily relies on it). I was thinking on simply generate the random height first, and then loop over every vertex to force its offending neighbors to lower/heighten itself accordingly. But alas it just doesn't seem to be the right way. Perhaps any of you ever done similar things in the past? I hope you could give me any advice on this matter. It's been boggling my mind. 

basically this is the game that inspires me.

program188-1.jpg

Advertisement

Midpoint displacement, also called the diamond-square algorithm, is trivially modified to handle that type of thing where you have zones with mandatory heights.

There are more complex algorithms out there which produce more pleasing results, but that one is easy to implement, was used in a bunch of older games, and with a bit of tuning can produce exactly the terrain grids you described.

This topic is closed to new replies.

Advertisement