Esempio n. 1
0
        private void GenerateFood()//places random food object in the screen randomly
        {
            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)
            };
        }
Esempio n. 2
0
        private void StartGame()
        {
            lblGameOver.Visible = false;
            new settings();
            Snake.Clear();
            circle head = new circle {
                X = 10, Y = 5
            };

            Snake.Add(head);
            lblScore.Text = settings.score.ToString();
            GenerateFood();
        }