Jump to content


Terrain Generation - Tile Based (X-Com UFO, Disgaea)


  • You cannot reply to this topic
4 replies to this topic

#1 XSportSeeker

    New Member

  • Members
  • Pip
  • 6 posts

Posted 20 December 2007 - 07:49 PM

Hi all.
I need some help to code a terrain generator for a tile based map.
It's for the final project on my Game Development course, and I have about 6 months to get it done.
I never dealt with random terrain generation before, so I need some basic tutorials.
The only thing I immagine is that it's generated based on several variables that will affect stuff like terrain type, scathering, leveling, props and other stuff.
I'm still choosing what to use, but it's probably either C++/openGl or XNA.

Any tips are welcome.

#2 Wernaeh

    Senior Member

  • Members
  • PipPipPipPip
  • 368 posts

Posted 21 December 2007 - 01:29 AM

Hey there :)

How to generate your terrain depends on several factors:

First, how large and how versatile need your terrain be ?
And second, how do you want to structure your terrain, what things do you want to have on it, and so on.

Basically, there are two approaches that may arbitrarily be combined.

First, there is the fractal approach:

Leave the entire generation process to some automated system, with little to no user intervention. This is best suited for creating very "natural" structures - such as basic height information. It fails (unless you use a very complicated algorithm) at building "thought-driven" objects, such as buildings, or any other manmade stuff. If you are into fractals, google for a guy named Perlin, he did a lot of research into fractal based image creation.

For illustration purposes, to generate simple fractal height maps, start with random height values for the four corners of your map - this essentially gives you a square with 4 height values. Subdivide this square by cutting it once through the middle, horizontally and vertically, leaving you 4 new squares, and 5 new points. Determine, for each new point, the new height at this point, by first interpolating the height of the 4 old points, and then adding some random height amount. Recurse on each of the four new squares, until you have touched each point in your terrain once -- note that your terrain height map needs to be power-of-two in each dimension and square for this to work.

The second approach is randomly combining premodelled tiles (for example, consider the buildings, the drop ship landing spot, and similar large, repeating tiles in the UFO games).

This basically requires the user to build these tiles (in an external tool maybe), and the user needs to specify certain combination restraints (such as, mounting spots for deco objects and similar). A random generator can then go on to attach new tiles to each mounting spot until each mounting spot is adequately filled. (As an example, I guess this is the way The Elder Scrolls: Daggerfall had its dungeons created).

Note the former way is much easier to implement, while the latter gives more "impressive" geometry.

You might also look on the Gamasutra site, they had an article once on terrain generation, I just failed to find the link right now.

Cheers,
- Wernaeh
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 21 December 2007 - 06:42 AM

Wernaeh - I could be wrong, but it sounded to me like he wants algorithms for creating maps for tile-based games, a la Civilization's random map generator or something like that.

But, XSportSeeker, in case you are talking about heightfield terrain generation, just try googling for "terrain generation" and "terrain synthesis" - you get a lot of hits, including academic papers describing advanced effects.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 Wernaeh

    Senior Member

  • Members
  • PipPipPipPip
  • 368 posts

Posted 21 December 2007 - 01:06 PM

I just went by the X-Com name in the title, which actually has isometric "heightmap"-like terrain and buildings and several other things atop of it. Come to think of it, Disgaea also sported some sort of isometric terrain, rather than a normal tilemap :)

Cheers,
- Wernaeh
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)

#5 Draconis

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 December 2007 - 01:08 AM

Hi,

I'm familiar with disgaea terrain which is just random isometric blocks, correct?
Something that i have done to achieve random isometric terrain is to have on a random chance it is either land, air or an object.
Usually you have a higher chance for air, then land etc. Depending on what you want you tweak the chance for each type.
So, anyway then you setup some rules which make it so that a land block can only occur on another land, objects can only be on land etc.
Obviously you'll need to initially generate some sort of land base for the rules to work on top of, I just had a single layer of land to start with. You could just as easily start with a random shape or change the rules so that the first land block just has a random location then land must be next to another land....etc.
I hope that helps, It may be nothing like you want?

Draconis





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users