From a7da2b1aeec39953d19293ba06203a1a0eaf506d Mon Sep 17 00:00:00 2001 From: sasha80 Date: Fri, 24 Nov 2023 09:55:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D1=81?= =?UTF-8?q?=D1=81=D0=B5.=20=D0=9F=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/tilemap.gd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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)