예제 #1
0
        //метод который спавнит еду
        private void SpawnFood()
        {
            int maxXPos = pbCanvas.Size.Width / Params.Width;
            int maxYPos = pbCanvas.Size.Height / Params.Height;

            Random random = new Random();

            food   = new Krug();
            food.X = random.Next(0, maxXPos);
            food.Y = random.Next(0, maxYPos);
        }
예제 #2
0
        private void Eat()
        {
            //Добавляем к телу круг
            Krug food = new Krug();

            food.X = Snake[Snake.Count - 1].X;
            food.Y = Snake[Snake.Count - 1].Y;

            Snake.Add(food);

            //Добавляем очки
            Params.Score += Params.Points;
            lblScore.Text = Params.Score.ToString();

            SpawnFood();
        }
예제 #3
0
        private void StartGame()
        {
            lblGameOver.Visible = false;

            new Params();

            //Создаем нового игрока
            Snake.Clear();
            Krug head = new Krug();

            head.X = 10;
            head.Y = 5;
            Snake.Add(head);


            lblScore.Text = Params.Score.ToString();
            SpawnFood();
        }