示例#1
0
        public void MaakBos(Bitmap bitmap)
        {
            Random r = new Random();

            for (int i = 0; i < 300; i++)
            {
                Boom boom = new Boom(i, r.Next(MinX + 10, MaxX - 10), r.Next(MinY + 10, MaxY - 10));

                if (!Bomen.Contains(boom))
                {
                    Bomen.Add(boom);
                }
                else
                {
                    i--;
                }
            }

            Graphics graphics = Graphics.FromImage(bitmap);
            Pen      pen      = new Pen(Color.Green);

            foreach (Boom boom in Bomen)
            {
                graphics.DrawEllipse(pen, boom.X, boom.Y, 10, 10);
            }
        }
示例#2
0
        public override bool Equals(object obj)
        {
            Boom   other   = obj as Boom;
            double afstand = Math.Sqrt(Math.Pow(this.X - other.X, 2) + Math.Pow(this.Y - other.Y, 2));

            return(other != null && afstand < 12);
        }
示例#3
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);
            }
        }
示例#4
0
 public void DichtsteBoom(Bitmap bitmap, Aap aap)
 {
     Boom laatsteBoom = aap.Bomen[^ 1];