Beispiel #1
0
        public static void Func()
        {
            while (true)
            {
                if (direction == 8)
                {
                    snake.Move(0, -1);
                }
                if (direction == 2)
                {
                    snake.Move(0, 1);
                }
                if (direction == 4)
                {
                    snake.Move(-1, 0);
                }
                if (direction == 6)
                {
                    snake.Move(1, 0);
                }

                if (snake.Eating(food))
                {
                    food.SetRandomPosition();
                }
                if (snake.Collision() || snake.WallCollision(wall))
                {
                    Console.Clear();
                    Console.SetCursorPosition(10, 10);
                    Console.WriteLine("GAME OVER!!!");
                    Console.ReadKey();
                    Console.Clear();
                    snake = new Snake();
                    wall  = new Wall(level);
                }
                snake.Draw();
                wall.Draw();
                food.Draw();
                Thread.Sleep(speed);
            }
        }