コード例 #1
0
        public void Form1_Load(object sender, EventArgs e)
        {
            Point startPoint = new Point(100, 100);
            Fiend first      = new Fiend(startPoint, false, 1, 50);

            fiends.Add(first);
            field = new Field(pictureBox1.Bounds);
        }
コード例 #2
0
        public void t_Tick(object sender, EventArgs e)
        {
            List <Point> position = new List <Point>();
            List <Color> color    = new List <Color>();

            foreach (Fiend animal in fiends)
            {
                if (animal.hungry < 1 && population < 500)
                {
                    animal.hungry = 50;
                    Fiend little = new Fiend(animal.pos, animal.Agressive, animal.speed, 50);
                    if (little.pos.X != 1000)
                    {
                        vacancymap[little.pos.X, little.pos.Y] = false;
                        newfiends.Add(little);
                        population++;
                    }
                }
                else
                {
                    vacancymap[animal.pos.X, animal.pos.Y] = true;
                    animal.Behavior();
                    vacancymap[animal.pos.X, animal.pos.Y] = false;
                }
                position.Add(animal.pos);
                color.Add(animal.color);
            }
            foreach (Fiend animal in newfiends)
            {
                fiends.Add(animal);
            }
            try
            {
                pictureBox1.Image.Dispose();
            }
            catch { }

            pictureBox1.Image = field.MakePicture(position, color);
        }