Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //начало координат в левом верхнем углу, ось х идет слева направо, ось у идет сверху вниз
            // ctrl+e,c = закомментировать несколько строк сразу
            // ctrl+k+d = выровнять код

            Console.SetBufferSize(80, 25); // задает параметры окна (ширина, высота) и убирает возможность прокрутки

            // отрисовка рамочки

            HorizontalLine upLine    = new HorizontalLine(0, 78, 0, '+');
            HorizontalLine downLine  = new HorizontalLine(0, 78, 24, '+');
            VerticalLine   leftLine  = new VerticalLine(0, 24, 0, '+');
            VerticalLine   rightLine = new VerticalLine(0, 24, 78, '+');

            upLine.DrawLine();
            downLine.DrawLine();
            leftLine.DrawLine();
            rightLine.DrawLine();

            // ставим точку

            Point p2 = new Point(4, 7, '#'); // второй объект из класса Point

            p2.DrawPoint();


            //задержка
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public Room(int roomWidth, int roomHeight)
        {
            //Отрисовка рамки
            HorizontalLine upLine    = new HorizontalLine(1, 0, roomWidth, '-');
            HorizontalLine downLine  = new HorizontalLine(1, roomHeight, roomWidth, '-');
            VerticalLine   leftLine  = new VerticalLine(0, 1, roomHeight - 1, '|');
            VerticalLine   rightLine = new VerticalLine(roomWidth, 1, roomHeight - 1, '|');

            lineList.Add(upLine);
            lineList.Add(downLine);
            lineList.Add(leftLine);
            lineList.Add(rightLine);

            //Отрисовка углов
            Point leftTop  = new Point(0, 0, '+');
            Point leftBot  = new Point(0, roomHeight, '+');
            Point rightTop = new Point(roomWidth, 0, '+');
            Point rightBot = new Point(roomWidth, roomHeight, '+');

            cornerList.Add(leftTop);
            cornerList.Add(leftBot);
            cornerList.Add(rightTop);
            cornerList.Add(rightBot);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            HorizontalLine hLine  = new HorizontalLine(0, 0, 16, '#');
            HorizontalLine hLine2 = new HorizontalLine(0, 10, 16, '#');

            hLine.Draw();
            hLine2.Draw();

            VerticalLine vLine  = new VerticalLine(0, 0, 10, '#');
            VerticalLine vLine2 = new VerticalLine(15, 0, 10, '#');

            vLine.Draw();
            vLine2.Draw();

            //Console.ReadKey();

            Point p = new Point(2, 3, '*');

            p.Draw();

            Random rand = new Random();
            int    x    = rand.Next(5, 10);
            int    y    = rand.Next(5, 10);

            Point p2 = new Point(x, y, '@');

            p2.Draw();

            var dir = Direction.Right;

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey();

                    switch (key.Key)
                    {
                    case ConsoleKey.LeftArrow:
                        dir = Direction.Left;
                        break;

                    case ConsoleKey.RightArrow:
                        dir = Direction.Right;
                        break;

                    case ConsoleKey.UpArrow:
                        dir = Direction.Up;
                        break;

                    case ConsoleKey.DownArrow:
                        dir = Direction.Down;
                        break;
                    }
                }

                Thread.Sleep(100);
                p.Move(dir);
            }

            Console.ReadLine();
        }