Esempio n. 1
0
 public void CheckCollision()
 {
     if (worm.IsIntersected(wall.body) || worm.CheckWall())
     {
         timer.Enabled = false;
         Console.Clear();
         Console.SetCursorPosition(15, 20);
         Console.Write("Game over!");
     }
     else if (worm.IsIntersected(food.body))
     {
         score++;
         if (score == 2)
         {
             degree++;
         }
         if (score == 5)
         {
             degree++;
         }
         Console.SetCursorPosition(41, 1);
         Console.WriteLine("Your score: " + score);
         Console.SetCursorPosition(41, 2);
         Console.WriteLine("Level: " + degree);
         worm.Eat(food.body);
         Thread.Sleep(200 - score);
         food.GenerateLocation(worm.body, wall.body);
         food.Draw();
     }
 }
Esempio n. 2
0
 public void CheckWall()
 {
     if (w.CheckWall())
     {
         gameover = true;
         Console.SetCursorPosition(33, 23);
         Console.WriteLine("GAME OVER");
         Environment.Exit(0);
     }
 }