public Snake(Point tail,int length,Diraction diraction) { plist = new List<Point>(); for (int i = 0; i <= length; i++) { Point p = new Point(tail); p.Move(i, diraction); plist.Add(p); } }
public void Move(int i, Diraction diraction) { if (diraction == Diraction.RIGHT) { x = x + i; } if (diraction == Diraction.LEFT) { x = x - i; } if (diraction == Diraction.UP) { y = y - i; } if (diraction == Diraction.DOWN) { y = y + i; } }
public static void Task17() { int rows = rand.Next(1, 20) / 2 + 1; int columns = rand.Next(1, 20) / 2 + 1; int[,] arr = new int[rows, columns]; int i = rows / 2; int j = columns / 2; int center_i = i; int center_j = j; var curr_dir = new Diraction(); while (i > 0 && j > 0 && i < arr.GetLength(0) && j < arr.GetLength(1)) { curr_dir++; if ((int)curr_dir > 3) { curr_dir = 0; } } //2-мерн масс, не неч по всем измерениям. Заполнить улиткой с середины. throw new NotImplementedException(); }
public abstract bool CanMove(Diraction diraction);
public override bool CanMove(Diraction diraction) { return(robot.CanMove(diraction)); }