Example #1
0
        public static void Init()
        {
            Console.CursorVisible = false;
            Console.SetWindowSize(70, 35);

            GameOver = false;

            // snake init
            List <Point> snake_body = new List <Point>();

            snake_body.Add(new Point(10, 10));
            snake_body.Add(new Point(9, 10));
            snake = new Snake(ConsoleColor.Yellow, (char)2, snake_body);


            // wall init
            List <Point> wall_body = new List <Point>();

            wall = new Wall(ConsoleColor.Red, '#', wall_body);

            // food init
            List <Point> food_body = new List <Point>();

            food_body.Add(new Point(0, 0));
            food = new food(ConsoleColor.Green, (char)2, food_body);
        }
Example #2
0
 public bool CanEat(food f)
 {
     if (body[0].x == f.body[0].x && body[0].y == f.body[0].y)
     {
         body.Add(new Point(f.body[0].x, f.body[0].y));
         Console.SetCursorPosition(f.body[0].x, f.body[0].y);
         Console.WriteLine(' ');
         return(true);
     }
     return(false);
 }