+ def undouble_coordinate(self, maps_size, coordinate):
+ y = maps_size.y * coordinate[0].y + coordinate[1].y
+ x = maps_size.x * coordinate[0].x + coordinate[1].x
+ return YX(y, x)
+
+ def get_view_offset(self, maps_size, center, radius):
+ yx_to_origin = self.undouble_coordinate(maps_size, center)
+ return yx_to_origin - YX(radius, radius)
+
+ def pos_in_view(self, pos, offset, maps_size):
+ return self.undouble_coordinate(maps_size, pos) - offset
+
+ def get_view(self, maps_size, get_map, radius, view_offset):
+ m = Map(size=YX(radius*2+1, radius*2+1)
+ for pos in m:
+ seen_pos = self.correct_double_coordinate(maps_size, (0,0),
+ pos + view_offset)
+ seen_map = get_map(seen_pos[0], False)
+ if seen_map is None:
+ seen_map = Map(size=maps_size)
+ m[pos] = seen_map[seen_pos[1]]
+ return m
+
+ def get_correcting_map_size(self, size, offset):
+ return size
+
+ def correct_double_coordinate(self, map_size, big_yx, little_yx):
+
+ def adapt_axis(axis):
+ maps_crossed = little_yx[axis] // map_size[axis]
+ new_big = big_yx[axis] + maps_crossed
+ new_little = little_yx[axis] % map_size[axis]
+ return new_big, new_little
+
+ new_big_y, new_little_y = adapt_axis(0)
+ new_big_x, new_little_x = adapt_axis(1)
+ return YX(new_big_y, new_big_x), YX(new_little_y, new_little_x)
+
+ def move(self, start_pos, direction, map_size):