Beispiel #1
0
        public void MaakApen(int aantal, Bitmap bitmap)
        {
            List <Boom>   ingenomenBomen = new List <Boom>();
            Random        r     = new Random();
            List <string> namen = new List <string>()
            {
                "Jens",
                "Jo",
                "Marnick",
                "Toon",
                "Robin",
                "Arne",
                "Steve",
                "Vlad",
                "Gregory",
                "Kevy"
            };


            for (int i = 0; i < aantal; i++)
            {
                int   step  = r.Next(0, 256);
                Color color = GetRainbowColor(step, 255, 128);
                int   naam  = r.Next(1, namen.Count);
                Aap   aap   = new Aap(i + 1, namen[naam], color);
                if (!Apen.Contains(aap))
                {
                    Apen.Add(aap);
                }
                else
                {
                    i--;
                }
            }
            for (int i = 0; i < Apen.Count; i++)
            {
                Boom rb = Bomen[r.Next(1, Bomen.Count)];
                if (!ingenomenBomen.Contains(rb))
                {
                    Apen[i].Bomen.Add(rb);
                    ingenomenBomen.Add(rb);
                }
                else
                {
                    i--;
                }
            }
            Graphics graphics = Graphics.FromImage(bitmap);

            foreach (Aap aap in Apen)
            {
                Brush brush = new SolidBrush(aap.Color);
                graphics.FillEllipse(brush, aap.Bomen[0].X, aap.Bomen[0].Y, 12, 12);
            }
        }
        static void Spel(Bitmap bitmap, Map map, Aap aap)
        {
            for (int i = 0; i < 200; i++)
            {
                map.DichtsteBoom(bitmap, aap);
            }

            /* while (true)
             * {
             *   map.DichtsteBoom(bitmap, aap);
             *   if(!map.Apen.Contains(aap))
             *   {
             *       break;
             *   }
             * }*/
        }
Beispiel #3
0
 public void DichtsteBoom(Bitmap bitmap, Aap aap)
 {
     Boom laatsteBoom = aap.Bomen[^ 1];