Beispiel #1
0
        public void VullBos()
        {
            int  xCo        = rand.Next(0, pcbBos.Width);
            int  yCo        = rand.Next(0, pcbBos.Height);
            boom nieuweBoom = new boom(xCo, yCo, boomId);

            bool bestaatBoom = false;

            foreach (boom b in bomen)
            {
                if (nieuweBoom._x == b._x && nieuweBoom._y == b._y)
                {
                    bestaatBoom = true;
                    break;
                }
                else
                {
                    bestaatBoom = false;
                }
            }

            if (bestaatBoom)
            {
                VullBos();
            }
            else
            {
                bomen.Add(nieuweBoom);
                boomId++;
            }
        }
Beispiel #2
0
 public Aap(int id, string naam, int x, int y, boom startboom)
 {
     _Id        = id;
     _Naam      = naam;
     _X         = x;
     _Y         = y;
     _startBoom = startboom;
 }
Beispiel #3
0
        public void apenVerspringen()
        {
            double dichtsbijzijndePunt = 10000;
            double afstand;

            foreach (Aap a in apen)
            {
                boom dichtsbijzijndeBoom = new boom(0, 0, 0);
                foreach (boom b in bomen)
                {
                    var afstand1 = Math.Pow((a._x - b._X), 2);
                    var afstand2 = Math.Pow((a._y - b._Y), 2);
                    afstand = Math.Sqrt(afstand1 + afstand2);
                    if (afstand < dichtsbijzijndePunt)
                    {
                        dichtsbijzijndePunt = afstand;
                        dichtsbijzijndeBoom = b;
                    }

                    dichstbijzijndeBomen.Add(dichtsbijzijndeBoom);
                }
            }
        }