private void GenerateFood() { int maxXPos = playground.Size.Width / Settings.Width; int maxYPos = playground.Size.Height / Settings.Height; Random random = new Random(); food = new Kolo { x = random.Next(0, maxXPos), y = random.Next(0, maxYPos) }; }
private void Eat() { Kolo circle = new Kolo { x = Snake[Snake.Count - 1].x, y = Snake[Snake.Count - 1].y }; Snake.Add(circle); Settings.Score += Settings.Points; lblScore.Text = Settings.Score.ToString(); GenerateFood(); }
private void StartGame() { lblGameOver.Visible = false; new Settings(); Snake.Clear(); Kolo head = new Kolo { x = 10, y = 5 }; Snake.Add(head); lblScore.Text = Settings.Score.ToString(); GenerateFood(); }