Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);

            Wall wall = new Wall(80, 25, '%');
            wall.Drow();
            /*VerticalLine vert_line_left = new VerticalLine(24, 0, 79, '%');
            vert_line_left.Drow();

            VerticalLine vert_line_right = new VerticalLine(24, 0, 0, '%');
            vert_line_right.Drow();

            HorizontalLine hor_line_bottom = new HorizontalLine(0, 78, 24, '%');
            hor_line_bottom.Drow();

            HorizontalLine hor_line_top = new HorizontalLine(0, 78, 0, '%');
            hor_line_top.Drow();*/

            Point start = new Point(15, 5, '*');
            Snake snake = new Snake(start, 8, Direction.RIGHT);
            snake.Drow();

            FoodCreator createfood = new FoodCreator(80, 25, '$');
            Point food = createfood.CreateFood();
            food.Drow();

            while(true)
            {
                if(wall.IsHit(snake) || snake.IsHitTail() )
                {
                    break;
                }
                if(snake.Eat(food))
                {
                    food = createfood.CreateFood();
                    food.Drow();
                }
                if(Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key);
                }
                Thread.Sleep(100);
                snake.Move();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);

            Wall wall = new Wall(80, 25);

            wall.Draw();

            //Отрисовка змейки
            Point p     = new Point(5, 4, '*');
            Snake snake = new Snake(p, 4, Direction.RIGHT);

            snake.Draw();

            FoodCreator foodCreator = new FoodCreator(80, 25, '@');
            Point       food        = foodCreator.CreateFood();

            food.Draw();

            while (true)
            {
                if (wall.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else
                {
                    snake.Move();
                }
                Thread.Sleep(100);

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);

            Wall walls = new Wall(80, 25);
            walls.Draw();

            //Отрисовка точек
            Point p = new Point(4, 5, '*');
            Snake snake = new Snake(p, 4, Direction.RIGHT);
            snake.Draw();

            FoodCreator foodCreator = new FoodCreator(80, 25, '$');
            Point food = foodCreator.CreateFood();
            food.Draw();

            while (true)
            {
                if (walls.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }

                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else
                {
                    snake.Move();
                }
                Thread.Sleep(100);

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
            WriteGameOver();
            Console.ReadLine();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Wall wall = new Wall(70, 24);

            wall.Draw();

            Point p     = new Point(4, 5, '*');
            Snake snake = new Snake(p, 2, Dir.RIGHT);

            snake.Draw();

            FoodCreator foodCreator = new FoodCreator(70, 24, '$');
            Point       food        = foodCreator.CreateFood();

            food.Draw();

            while (true)
            {
                if (wall.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else
                {
                    snake.Move();
                }

                Thread.Sleep(100);
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
            }
            WriteGameOver();
            Console.ReadLine();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Wall wall = new Wall(120, 15);

            #region Points
            //Змейка
            Point start = new Point(4, 5, '*');                 // Хвост
            Snake snake = new Snake(start, 4, direction.RIGTH); // Создаём змейку
            snake.Draw();                                       // Рисуем её
            snake.Move();

            //Еда
            FoodCreator foodCreator = new FoodCreator(120, 30, '$');
            Point       food        = foodCreator.CreateFood();
            food.Draw();
            #endregion

            while (true)
            {
                if (wall.IsHit(snake) || snake.IsHitTail())
                {
                    break;
                }
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.dirChange(key.Key);
                }
                Thread.Sleep(100);
                snake.Move();
            }
        }