I am creating an 2D XNA Tile Based Platformer. I have a tile engine and a world/terrain generator. However, I am trying to create biomes or areas, For example, Desert in one part of the world, ocean on the ends, City in the middle, forests scattered around etc. I can easily make it generate them, but My problem is defining the actual areas to be generated in.

  • \$\begingroup\$ Maybe if you post your generation code we could help you more... \$\endgroup\$ – Nate Jul 18 '12 at 17:36
  • \$\begingroup\$ Possible Duplicate: gamedev.stackexchange.com/questions/20551/… \$\endgroup\$ – DampeS8N Jul 18 '12 at 17:42
  • \$\begingroup\$ @DampeS8N, My game is a sidescroller. @_Nate Bross, My generator can generate different things by defining an area to generate \$\endgroup\$ – Cyral Jul 18 '12 at 17:48
  • 2
    \$\begingroup\$ possible duplicate of Random map generation \$\endgroup\$ – MichaelHouse Jul 18 '12 at 17:51
  • \$\begingroup\$ Yes, I know you're doing a side scroller, the same concepts still apply. \$\endgroup\$ – MichaelHouse Jul 18 '12 at 17:53

Without any specific knowledge of your generation algorithm, I would suggest the following.

Assuming that your world is defined in a multi-dimensional array Tile[999,99]

  1. Decide how many "biomes" you want and of what type
  2. Define the size of each biome
  3. Go through your world array, and pick a start point for each biome
  4. Update the world array with each biome's tile data

For example:

Tile[,] World = new Tile[999,99];
Tile[,] Ocean = new Tile[50,10];
// assume we want the ocean to be top left of the world, flowing off the edge
for(int i = 0; i < 50; i++)
    for(int j = 0; j < 10; j++)
        World[i,j] = Ocean[i,j];

You could, as @Nathan suggested, use a distance from water to define which tile-set to use for each area. This could help keep your maps looking fresh and consistent, yet still be generated on-demand.

  • 1
    \$\begingroup\$ A side scroller makes it even more simple, you just have to decide the start x and stop x for each biome. \$\endgroup\$ – Nate Jul 18 '12 at 18:59
  • \$\begingroup\$ I actually ended up creating a class to store the end and start of a biome, and an enum on the biome type, But based on your advise \$\endgroup\$ – Cyral Jul 19 '12 at 0:49
  • \$\begingroup\$ @Cyral Great! Glad it was helpful. \$\endgroup\$ – Nate Jul 19 '12 at 14:38

There is a great discussion of procedurally creating random biomes on a map in Polygonal Map Generation for Games by Amit Patel. His maps are arbitrary polygonal shapes, not tiles, but the same ideas should be applicable.

Briefly: generate elevation and lakes/rivers on your map using whatever method works for you, then define biomes in terms of elevation and moisture (distance to water). There is a nice table in the article that suggests different biomes for different combinations of elevation and moisture level.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.