Exemplo n.º 1
0
        public Walls(int mapWidth, int mapHeight)
        {
            wallList = new List <Figure>();

            Horizontalline upLine    = new Horizontalline(0, mapWidth - 2, 0, '+');
            Horizontalline downLine  = new Horizontalline(0, mapWidth - 2, mapHeight - 1, '+');
            Verticalline   leftLine  = new Verticalline(0, mapHeight - 1, 0, '+');
            Verticalline   rightLine = new Verticalline(0, mapHeight - 1, mapWidth - 2, '+');

            wallList.Add(upLine);
            wallList.Add(downLine);
            wallList.Add(leftLine);
            wallList.Add(rightLine);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(1, 1);
            Console.SetBufferSize(80, 25);
            Console.SetWindowSize(80, 25);

            Point lefttop     = new Point(0, 0, ' ');
            Point rightbottom = new Point(79, 23, ' ');

            // Рисуем рамочку
            char           sym        = '+';
            Horizontalline topline    = new Horizontalline(lefttop.x, rightbottom.x, lefttop.y, sym);
            Horizontalline bottomline = new Horizontalline(lefttop.x, rightbottom.x, rightbottom.y, sym);
            Verticalline   leftline   = new Verticalline(lefttop.x, lefttop.y++, rightbottom.y--, sym);
            Verticalline   rightline  = new Verticalline(rightbottom.x, lefttop.y++, rightbottom.y--, sym);

            topline.Draw();
            bottomline.Draw();
            leftline.Draw();
            rightline.Draw();

            Point p     = new Point(3, 5, '█');
            Snake snake = new Snake(p, 10, Direction.RIGHT);

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    snake.HandleKey(key.Key);
                }
                System.Threading.Thread.Sleep(100);
                snake.Move();
            }

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

            Point lefttop = new Point(0, 0, ' ');
            Point rightbottom = new Point(79, 23, ' ');

            // Рисуем рамочку
            char sym = '+';
            Horizontalline topline = new Horizontalline(lefttop.x, rightbottom.x, lefttop.y, sym);
            Horizontalline bottomline = new Horizontalline(lefttop.x, rightbottom.x, rightbottom.y, sym);
            Verticalline leftline = new Verticalline(lefttop.x, lefttop.y++, rightbottom.y--, sym);
            Verticalline rightline = new Verticalline(rightbottom.x, lefttop.y++, rightbottom.y--, sym);
            topline.Draw();
            bottomline.Draw();
            leftline.Draw();
            rightline.Draw();

            Point p = new Point(3, 5, '█');
            Snake snake = new Snake(p, 10, Direction.RIGHT);

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(true);
                    snake.HandleKey(key.Key);
                }
                System.Threading.Thread.Sleep(100);
                snake.Move();
            }

            Console.ReadLine();
        }