public bool IsWall(Point area) { Control child = gameScreen.GetChildAtPoint(area); if (child != null) { return(child.Name.Contains("wall")); } else { return(false); } }
public List <OrdinaryFood> CreateFoods() { List <OrdinaryFood> ordinaryFoods = new List <OrdinaryFood>(); int foodCount = 0; for (int currentYPosition = 0; currentYPosition < gameScreen.Height; currentYPosition += IMAGEHEIGHT) { for (int currentXPosition = 0; currentXPosition < gameScreen.Width; currentXPosition += IMAGELENGHT) { Point currentPoint = new Point(currentXPosition, currentYPosition); if (gameScreen.GetChildAtPoint(currentPoint) == null) { Label newFoodImage = new Label(); foodCount++; newFoodImage.Font = new Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162))); newFoodImage.ForeColor = Color.Yellow; newFoodImage.Location = new Point(currentXPosition, currentYPosition); newFoodImage.Name = "food" + (foodCount).ToString(); newFoodImage.Size = new Size(IMAGELENGHT, IMAGEHEIGHT); newFoodImage.TabIndex = 56; newFoodImage.Text = "•"; gameScreen.Controls.Add(newFoodImage); OrdinaryFood newOrdinaryFood = new OrdinaryFood { image = newFoodImage }; ordinaryFoods.Add(newOrdinaryFood); } } } return(ordinaryFoods); }