Last active
January 4, 2016 18:29
-
-
Save wmiller/8661448 to your computer and use it in GitHub Desktop.
XML Database for Unity (Part 1) Build Map Method 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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