Exemple #1
0
 public Point GetNextPoint()
 {
     Point head = pList.Last();
     Point nextPoint = new Point(head);
     nextPoint.Move(1, _direction);
     return nextPoint;
 }
Exemple #2
0
        public Point GetNextPoint()
        {
            Point head      = pList.Last();
            Point nextPoint = new Point(head);

            nextPoint.Move(1, direction);
            return(nextPoint);
        }
Exemple #3
0
 public Snake(Point tail, int lenght, Direction direction)
 {
     plist = new List <Point>();
     for (int i = 0; i < lenght; i++)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         plist.Add(p);
     }
 }
Exemple #4
0
 public Snake(Point tail, int lenght, Direction _direction)
 {
     direction = _direction;
     for (int i = 0; i < lenght; ++i)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         points.Add(p);
     }
 }
Exemple #5
0
 public Snake( Point tail, int length, Direction direction)
 {
     pList = new List<Point>();
     _direction = direction;
     for (int i = 0; i < length; i++)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         pList.Add(p);
     }
 }
Exemple #6
0
 public Snake(Point tail, int lenght, Direction _direction)
 {
     direction = _direction;
     pList = new List<Point>();
     for (int i = 0; i < lenght; i++)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         pList.Add(p);
     }
 }
Exemple #7
0
 public Snake(Point head, int lenth, Direction direction)
 {
     points    = new List <Point>();
     Direction = direction;
     for (int i = 0; i < lenth; i++)
     {
         Point point = new Point(head);
         point.Move(i, direction);
         points.Add(point);
     }
 }
Exemple #8
0
 public Snake(Point tail, int length, Direction _direction)
 {
     direction = _direction;
     pList     = new List <Point>();
     for (int i = 0; i < length; i++)
     {
         Point p = new Point(tail);
         p.Move(i, direction);
         pList.Add(p);
     }
 }
Exemple #9
0
        //Конструктор для отображения змеи на экране
        public Snake(Point tail, int length, Direction direction)
        {
            this.direction = direction;

            //создаём коорданаты тела змеи из координат(точки) хвоста, длины и направления движения
            for (int offset = 0; offset < length; offset++)
            {
                //создаём точку из точки хвоста
                Point point = new Point(tail);
                //корректируем её на нужное смещение по нужной оси x или y
                point.Move(ref point, direction, offset);
                //вносим значение координаты в лист
                coordinats.Add(point);
            }
        }
Exemple #10
0
        //Метод движения змеи
        public void Move()
        {
            //получили точку хвоста
            Point tail = coordinats.First();

            //удаляем её из листа
            coordinats.RemoveAt(0);
            //получаем координату сдвига головы
            Point head = new Point(coordinats.Last());

            head.Move(ref head, direction, 1);
            //добавляем её в лист
            coordinats.Add(head);
            //стираем старую точку хвоста
            tail.Clear(ref tail);
            //рисуем точку головы
            head.Draw();
        }