public Point GetNextPoint() { Point head = pList.Last(); Point nextPoint = new Point(head); nextPoint.Move(1, _direction); return nextPoint; }
public Point GetNextPoint() { Point head = pList.Last(); Point nextPoint = new Point(head); nextPoint.Move(1, direction); return(nextPoint); }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
//Конструктор для отображения змеи на экране 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); } }
//Метод движения змеи 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(); }