Exemplo n.º 1
0
        public Walls(int mapWigth, int mapHeight)
        {
            HorizontalLine topLine    = new HorizontalLine(0, mapWigth - 2, 0, '+');
            HorizontalLine bottomLine = new HorizontalLine(0, mapWigth - 2, mapHeight - 1, '+');
            VerticalLine   leftLine   = new VerticalLine(0, mapHeight - 1, 0, '+');
            VerticalLine   rigthLine  = new VerticalLine(0, mapHeight - 1, mapWigth - 2, '+');

            _wallList = new List <Figure>();
            _wallList.Add(topLine);
            _wallList.Add(bottomLine);
            _wallList.Add(leftLine);
            _wallList.Add(rigthLine);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);


            // Draw Lines
            HorizontalLine line = new HorizontalLine(0, 78, 0, '+');

            line.Drow();

            VerticalLine line2 = new VerticalLine(0, 24, 0, '+');

            line2.Drow();

            VerticalLine line3 = new VerticalLine(0, 24, 78, '+');

            line3.Drow();

            HorizontalLine line4 = new HorizontalLine(0, 78, 24, '+');

            line4.Drow();



            //Draw point
            Point p     = new Point(4, 5, '*');
            Snake snake = new Snake(p, 4, Direction.RIGHT);

            snake.Drow();


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

            food.Draw();



            while (true)
            {
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Draw();
                }
                else
                {
                    snake.Move();
                }
            }
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.HandleKey(key.Key);
                }
                Thread.Sleep(100);
                snake.Move();
            }


            Console.ReadLine();
        }