Пример #1
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);
        }
Пример #2
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();
        }