Exemple #1
0
        public bool AddObject(double x, double y, double edg)
        {
            GOSquare Vasya1 = new GOSquare(edg,
                                           new Coords(x, y),
                                           "Vasya", mCanvas,
                                           new ClrRGB(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255)));

            bool isin = true;

            foreach (GameObject gsq in GameObjects)
            {
                if (!Vasya1.Intersect(gsq.Crds) == false)
                {
                    isin = false;
                }
            }

            if (isin)
            {
                GameObjects.Add(Vasya1);
                Vasya1.AddToCanv();
            }
            else
            {
                isin = false;
            }

            return(!isin);
        }
Exemple #2
0
        public Game(Canvas mainCanvas, TextBlock debugInfoTextBox)
        {
            mCanvas     = mainCanvas;
            GameObjects = new List <GameObject>();
            rand        = new Random();
            mTextBox    = debugInfoTextBox;

            Road = new GORectangle(50, mCanvas.Width,
                                   new Coords(0, 0),
                                   "DOROGA", mCanvas,
                                   new ClrRGB(10, 10, 10));

            Road.AddToCanv();
            GameObjects.Add(Road);

            RedSquare = new GOSquare(100,
                                     new Coords(100, 100),
                                     "RedSquare", mCanvas,
                                     new ClrRGB(255, 0, 0));

            RedSquare.Speed = 1;

            RedSquare.AddToCanv();
            GameObjects.Add(RedSquare);
        }