Exemple #1
0
        private void generateFood()
        {
            int maxXPos = pbArena.Size.Width / level.cellWidth;
            int maxYPos = pbArena.Size.Height / level.cellHeight;

            Random rand = new Random();
            food = new cell();
            food.x = rand.Next(0, maxXPos);
            food.y = rand.Next(0, maxYPos);
        }
Exemple #2
0
        private void StartGame()
        {
            labelGameOver.Visible = false;
            new level();
            Player.Clear();

            cell head = new cell();

            head.x = pbArena.Size.Width / (level.cellWidth * 2);
            head.y = pbArena.Size.Height / (level.cellHeight * 2);
            Player.Add(head);

            labelScore.Text = level.score.ToString();
            generateFood();
        }