diff --git a/scenes/tilemap.gd b/scenes/tilemap.gd index 53a29f55..c19caee4 100644 --- a/scenes/tilemap.gd +++ b/scenes/tilemap.gd @@ -80,10 +80,10 @@ func request_tile(tile: mercator.Tile, server_addr: String) -> Error: return map_request.request(tile_addr) -func img_tile_to_map_image(image: Image, dst_pos: Vector2i, tile: mercator.Tile): +func img_tile_to_map_image(image: Image, dst_pos: Vector2i): image.adjust_bcs(map_bcs.x, map_bcs.y, map_bcs.z) map_image.blit_rect(image, map_tile, dst_pos) - map_rects.append(Rect2i(dst_pos.x, dst_pos.y, tile.x, tile.y)) # сохранить корневую плитку + func _process(_delta: float): @@ -139,13 +139,15 @@ func _map_request_completed(result, response_code, headers, data): var sx: float = float(map_tile.size.x) / (bounds.east - bounds.west) * (lng_c - tile.lng) + map_tile.size.x / 2 # Cмещение в пискселях центра плитки от заданной точки по горизонтали. var sy: float = float(map_tile.size.y) / (bounds.north - bounds.south) * (lat_c - tile.lat) - map_tile.size.y / 2 # Cмещение в пискселях центра плитки от заданной точки по вертикали. var dst_pos: Vector2i = Vector2i(sx, -sy) - img_tile_to_map_image(img_tile, dst_pos, tile) + img_tile_to_map_image(img_tile, dst_pos) + map_rects.append(Rect2i(dst_pos.x, dst_pos.y, tile.x, tile.y)) else: # Отображение соседних плиток var root_rect: Rect2i = map_rects[0] # Получить корневую плитку var dx: int = tile.x - root_rect.size.x # Вычислить смещение дочерней плитки относительно корневой var dy: int = tile.y - root_rect.size.y var dst_pos: Vector2i = root_rect.position + Vector2i(dx, dy) * map_tile.size - img_tile_to_map_image(img_tile, dst_pos, tile) + img_tile_to_map_image(img_tile, dst_pos) + map_rects.append(Rect2i(dst_pos.x, dst_pos.y, tile.x, tile.y)) mark_image_center(map_image) texture = ImageTexture.create_from_image(map_image)