mardi 2 février 2016

Random generate tile world c# xna

Platform game in C# / XNA.
I have a int[,] array that I fill for example:

int[,] {
  {0, 0, 0, 1},
  {0, 0, 1, 2},
  {0, 1, 2, 2},
  {1, 2, 2, 2},
}

Output:
[air][air][air][grass]
[air][air][grass][dirt]
[air][grass][dirt][dirt]
[grass][dirt][dirt][dirt]

Now I have a random function that fills the int array:

Random rnd = new Random();

for (int i = 0; i < 8; i++)
{
  for (int x = 0; x < 23; x++)
  {
     tiles[i, x] = rnd.Next(0, 3);
  }
}

output:
Platformer Example

What is a good algorithm to generate the map properly?
Like above 45% more air and on top of dirt I want grass.




Aucun commentaire:

Enregistrer un commentaire