Grid.shift() - shift whole coordinate system

This commit is contained in:
Stefan Harmuth 2022-12-22 09:35:09 +01:00
parent 798e8c3faa
commit 47446f3f35

View File

@ -287,6 +287,15 @@ class Grid:
else:
raise NotImplementedError(mode)
def shift(self, shift_x: int = None, shift_y: int = None):
self.minX, self.minY = self.minX + shift_x, self.minY + shift_y
self.maxX, self.maxY = self.maxX + shift_x, self.maxY + shift_y
coords = self.__grid
self.__grid = {}
for c, v in coords.items():
nc = Coordinate(c.x + shift_x, c.y + shift_y)
self.set(nc, v)
def getPath_BFS(self, pos_from: Coordinate, pos_to: Coordinate, includeDiagonal: bool, walls: List[Any] = None,
stop_at_first: Any = None) -> Union[None, List[Coordinate]]:
queue = deque()