Exemple #1
0
        Graphics g;//графический контекст
        private void Form1_Load(object sender, EventArgs e)
        {
            pb.Image = new Bitmap(pb.Width, pb.Height);
            g        = Graphics.FromImage(pb.Image);
            //o1 = new Obstacle { x = 50, y = 100, d =40 };
            //o2 = new Obstacle { x = 90, y = 70, d =40 };

            world = new world();
            //r = new Robot();

            timer1.Enabled = true;
        }
Exemple #2
0
        public float CheckDistance(world w)
        {
            float step = 1;
            float s = (float)Math.Sin(a);
            float c = (float)Math.Cos(a);
            float x_ = x, y_ = y;

            for (float i = 0; i < maxDist; i += step)
            {
                x_ += step * c;
                y_ += step * s;
                if (CheckPoint(x_, y_, w.obstacles))
                {
                    return((float)Math.Sqrt(x_ * x_ + y_ * y_));
                }
            }
            return(maxDist);
        }