Ejemplo n.º 1
0
 void CheckWallColision()
 {
     if (wall.CheckIntersection(worm.body) == true)
     {
         worm.Clear();
         food.Clear();
         wall.Clear();
         Console.WriteLine("     ");
         Console.WriteLine("Game over");
         Environment.Exit(0);
     }
 }
Ejemplo n.º 2
0
        static void TestFood()
        {
            Food food = new Food('$', ConsoleColor.Red);

            food.Draw();

            Console.ReadKey();

            food.Clear();
        }
Ejemplo n.º 3
0
        static void Draw()
        {
            Console.Clear();

            snake.Draw();
            food.Draw();
            wall.Draw();
            while (alive)
            {
                Thread.Sleep(250);
                snake.Clear();

                snake.Move();
                if (snake.intersect((GameObject)food))
                {
                    snake.upgrade();
                    food.Clear();
                    food.setPoint(getEmptyCell());
                    food.Draw();
                    score++;
                    curscore++;
                }
                if (wall.intersect(snake.points[0]))
                {
                    alive = false;
                    break;
                }


                snake.Draw();

                Console.SetCursorPosition(0, HEIGHT);
                Console.Write("Score: {0}   Level: {1}", score, level);
                if (curscore == 5)
                {
                    curscore = 0;
                    level++;
                    Console.Clear();
                    wall = new Wall();
                    for (int i = 1; i <= 10 * (level + 1); i++)
                    {
                        wall.points.Add(getEmptyCell());
                    }

                    snake.Draw();
                    food.Draw();
                    wall.Draw();

                    Thread.Sleep(1000);
                }
            }
        }