Difference between revisions of "Implementing weather changes that affect animals"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 14: Line 14:
 
                     AdvanceTimePeriod();
 
                     AdvanceTimePeriod();
 
                 }
 
                 }
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="csharp">
 +
 +
        private double DistanceBetween(int x1, int y1, int x2, int y2)
 +
        {
 +
            if (Season==0)
 +
            {
 +
                return (Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2))+3);
 +
            }
 +
            else
 +
            return Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
 +
        }
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 12:18, 14 March 2017

 
                if (menuOption == 1)
                {
                    TimePeriod++;
                    Season = TimePeriod % 4;
                    ShowDetail = true;
                    AdvanceTimePeriod();
                }
                if (menuOption == 2)
                {
                    TimePeriod++;
                    Season = TimePeriod % 4;
                    ShowDetail = false;
                    AdvanceTimePeriod();
                }
 

        private double DistanceBetween(int x1, int y1, int x2, int y2)
        {
            if (Season==0)
            {
                return (Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2))+3);
            }
            else
            return Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
        }