Exemple #1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(1, 1);
            Console.SetBufferSize(80, 25);
            Console.SetWindowSize(80, 25);

            HorisontalLine upline    = new HorisontalLine(0, 78, 0, '+');
            VerticalLine   rigthline = new VerticalLine(0, 0, 24, '+');
            HorisontalLine downline  = new HorisontalLine(0, 78, 24, '+');
            VerticalLine   leftline  = new VerticalLine(78, 0, 24, '+');

            upline.Draw();
            rigthline.Draw();
            downline.Draw();
            leftline.Draw();

            Point p     = new Point(4, 5, '*');
            Snake snake = new Snake(p, 3, Direction.RIGTH);

            snake.Draw();

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

            food.Drow();

            while (true)
            {
                if (snake.Eat(food))
                {
                    food = foodCreator.CreateFood();
                    food.Drow();
                }
                else
                {
                    snake.Move();
                }
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey();
                    snake.directionOfMovement(key.Key);
                }
                Thread.Sleep(300);
                snake.Move();
            }
        }
Exemple #2
0
        internal void Move()
        {
            Point tail = pList.First();

            pList.Remove(tail);
            Point head = GetNextPoint();

            pList.Add(head);

            tail.Clear();
            head.Drow();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Point p1 = new Point(1, 3, '*');

            p1.Drow();

            Point p2 = new Point(4, 5, '#');

            p2.Drow();

            Console.ReadLine();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Point p1 = new Point();

            p1.x   = 1;
            p1.y   = 3;
            p1.sym = '*';
            p1.Drow();

            Point p2 = new Point();

            p2.x   = 4;
            p2.y   = 5;
            p2.sym = '#';
            p2.Drow();

            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Point p1 = new Point(1, 2, '*');

            p1.Drow();

            Point p2 = new Point(4, 5, '#');

            p2.Drow();

            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.Draw();
            downLine.Draw();
            leftline.Draw();
            rightline.Draw();

            Console.ReadLine();
        }