+ def _set_all_tiles(self, tile_index: int) -> None:
+ """Set all tiles to the given tile index"""
+ if tile_index >= self._tiles_in_bitmap:
+ raise ValueError("Tile index out of bounds")
+ self._tiles = bytearray(
+ (self._width_in_tiles * self._height_in_tiles) * [tile_index]
+ )
+ self._full_change = True
+
+ def _set_tile(self, x: int, y: int, tile_index: int) -> None:
+ self._tiles[y * self._width_in_tiles + x] = tile_index
+ temp_area = Area()
+ if not self._partial_change:
+ tile_area = self._dirty_area
+ else:
+ tile_area = temp_area
+ top_x = (x - self._top_left_x) % self._width_in_tiles
+ if top_x < 0:
+ top_x += self._width_in_tiles
+ tile_area.x1 = top_x * self._tile_width
+ tile_area.x2 = tile_area.x1 + self._tile_width
+ top_y = (y - self._top_left_y) % self._height_in_tiles
+ if top_y < 0:
+ top_y += self._height_in_tiles
+ tile_area.y1 = top_y * self._tile_height
+ tile_area.y2 = tile_area.y1 + self._tile_height
+
+ if self._partial_change:
+ self._dirty_area.union(temp_area, self._dirty_area)
+
+ self._partial_change = True
+
+ def _set_top_left(self, x: int, y: int) -> None:
+ self._top_left_x = x
+ self._top_left_y = y
+ self._full_change = True
+