Пример #1
0
        static void Main(string[] args)
        {
            Console.SetBufferSize(80, 25);

            Figure H1 = new HorizontalLine(0, 79, 0, '+');

            H1.Draw();
            Figure H2 = new HorizontalLine(0, 79, 23, '+');

            H2.Draw();
            Figure V1 = new VerticalLine(0, 0, 23, '+');

            V1.Draw();
            Figure V2 = new VerticalLine(79, 0, 23, '+');

            V2.Draw();


            WallsCreator W1 = new WallsCreator(2, 10, Direction.LEFT, 79, 23);

            W1.Draw();
            WallsCreator W2 = new WallsCreator(2, 10, Direction.DOWN, 79, 23);

            W2.Draw();



            Point p1 = new Point(4, 8, '#');
            Snake s1 = new Snake(p1, 7, Direction.RIGHT);

            s1.Draw();
            FoodCreator foodCr = new FoodCreator(79, 23, '@');
            Point       food   = foodCr.Create();

            food.Print(ConsoleColor.Red);

            while (true)
            {
                if (s1.eat(food))
                {
                    food = foodCr.Create();
                    food.Print(ConsoleColor.Red);
                }
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    s1.HandControl(key);
                }

                s1.Move();
                Thread.Sleep(150);
            }
        }
Пример #2
0
        public Walls(int lenght, int weight)
        {
            wallList = new List <Figure>();
            HorizontalLine LeftLine  = new HorizontalLine(2, 0, weight - 1, '+');
            HorizontalLine RightLine = new HorizontalLine(lenght - 2, 0, weight - 1, '+');
            VerticalLine   UpLine    = new VerticalLine(2, lenght - 2, 0, '+');
            VerticalLine   DownLine  = new VerticalLine(2, lenght - 2, weight - 1, '+');

            wallList.Add(LeftLine);
            wallList.Add(RightLine);
            wallList.Add(UpLine);
            wallList.Add(DownLine);
        }
Пример #3
0
        public Walls(int mapWeight, int mapHeight)
        {
            wallList = new List <Figure>();

            HorizontalLine gorLineTop    = new HorizontalLine(0, mapWeight - 2, 0, '+');
            HorizontalLine gorLineBottom = new HorizontalLine(0, mapWeight, mapHeight - 1, '+');
            VerticalLine   verLineLeft   = new VerticalLine(0, 0, mapHeight - 1, '+');
            VerticalLine   verLineRight  = new VerticalLine(mapWeight - 2, 0, mapHeight - 1, '+');

            wallList.Add(gorLineTop);
            wallList.Add(gorLineBottom);
            wallList.Add(verLineLeft);
            wallList.Add(verLineRight);
        }