Exemplo n.º 1
0
        public static double Noise(int x, int y)
        {
            //returns -1 to 1
            double total = 0.0;
            double freq = NoiseGenerator.Frequency, amp = NoiseGenerator.Amplitude;

            for (int i = 0; i < NoiseGenerator.Octaves; ++i)
            {
                total = total + NoiseGenerator.Smooth(x * freq, y * freq) * amp;
                freq *= 2;
                amp  *= NoiseGenerator.Persistence;
            }
            if (total < -2.4)
            {
                total = -2.4;
            }
            else if (total > 2.4)
            {
                total = 2.4;
            }

            return(total / 2.4);
        }