Beispiel #1
0
        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)
            };
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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();
        }