Beispiel #1
0
        private void GenerateFood()
        {
            int maxXPos = pbcanvas.Size.Width / Settings.Width;
            int maxYPos = pbcanvas.Size.Height / Settings.Height;

            Random random = new Random();

            food = new circle
            {
                X = random.Next(0, maxXPos), Y = random.Next(0, maxYPos)
            };
        }
Beispiel #2
0
        private void Eat()
        {
            circle Circle = new circle
            {
                X = snake_Game[snake_Game.Count - 1].X, Y = snake_Game[snake_Game.Count - 1].Y
            };

            snake_Game.Add(Circle);


            Settings.Score += Settings.Points;
            labelscore.Text = Settings.Score.ToString();
            GenerateFood();
        }
Beispiel #3
0
        private void StartGame()
        {
            lblGameOver.Visible = false;
            new Settings();
            snake_Game.Clear();
            circle head = new circle();

            {
                head.X = 10;
                head.Y = 5;
            }
            snake_Game.Add(head);

            labelscore.Text = Settings.Score.ToString();
            GenerateFood();
        }