public Snake(Point tail, int length, Snake_direction dir) { this.dir = dir; point_list = new List <Point>(); for (int i = 0; i < length; i++) { Point p = new Point(tail); p.move(i, dir); point_list.Add(p); } }
public void move(int offset, Snake_direction s_dir) { if (s_dir == Snake_direction.RIGHT) { this.x += offset; } else if (s_dir == Snake_direction.LEFT) { this.x -= offset; } else if (s_dir == Snake_direction.DOWN) { this.y += offset; } else if (s_dir == Snake_direction.UP) { this.y -= offset; } }
public void process_key(ConsoleKey key) { if (key == ConsoleKey.LeftArrow) { dir = Snake_direction.LEFT; } else if (key == ConsoleKey.RightArrow) { dir = Snake_direction.RIGHT; } else if (key == ConsoleKey.UpArrow) { dir = Snake_direction.UP; } else if (key == ConsoleKey.DownArrow) { dir = Snake_direction.DOWN; } }