Exemple #1
0
        } //MakeRandomMap Function

        public static float[,] MakePerlinNoiseMap(int width, int height, Noise.PerlinNoise perlin, float smoothness = 10.0F, int iterations = 4)
        {
            float[,] results = new float[width, height];

            float smoothnessx = smoothness * width / 40;
            float smoothnessy = smoothness * height / 40;
            int   amplitude   = 0;
            float n           = 0.0f;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    n         = 0.0f;
                    amplitude = 2;
                    // Generate the terrain
                    // 'n' is the height value of the terrain
                    for (int i = 0; i < iterations; i++)
                    {
                        n          = n + ((float)perlin.Noise(x / smoothnessx * amplitude, y / smoothnessy * amplitude) + 1.0f) / (float)amplitude;
                        amplitude *= 2;
                    } //next i

                    results[x, y] = n;
                } //next x
            }     //next y

            return(results);
        } //MakeNoiseMap Function
Exemple #2
0
        } //MakeNoiseMap Function

        public static float[,] MakeCloudsMap(int width, int height, Noise.PerlinNoise perlin, int iterations = 4)
        {
            float[,] results = new float[width, height];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    results[x, y] = (float)perlin.Noise(x, y, iterations, 1 / width, 1 / height);
                } //next x
            }     //next y

            return(results);
        } //MakeClouds Function