Skip to content

Instantly share code, notes, and snippets.

@wmiller
Last active January 4, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmiller/8661448 to your computer and use it in GitHub Desktop.
Save wmiller/8661448 to your computer and use it in GitHub Desktop.
XML Database for Unity (Part 1) Build Map Method 1
public void BuildMap(int width, int height)
{
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
// Get a noise value
float noiseX = (float)x / width * 6.0f;
float noiseY = (float)y / height * 6.0f;
float noise = Mathf.PerlinNoise(noiseX, noiseY);
// Convert noise value to height
int height = Mathf.RoundToInt(noise * 3);
// Place a tile
PlaceTile(x, y, height);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment