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); }
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); }
public MainWindow() { InitializeComponent(); GOSquare Square1 = new GOSquare(45, new Coords(40, 80), "Vasya"); Rectangle Sq1Rct = Square1.SquareRect; MainCanvas.Children.Add(Sq1Rct); Canvas.SetLeft(Sq1Rct, Square1.crd.x); Canvas.SetBottom(Sq1Rct, Square1.crd.y); }