Beispiel #1
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);
                }
            }
        }