diff --git a/arcade/tilemap/tilemap.py b/arcade/tilemap/tilemap.py index 9d86e2708..0099cec72 100644 --- a/arcade/tilemap/tilemap.py +++ b/arcade/tilemap/tilemap.py @@ -918,12 +918,14 @@ def _process_object_layer( shape = [x + offset[0], y + offset[1]] else: - x = cur_object.coordinates.x + offset[0] - y = cur_object.coordinates.y + offset[1] - sx = x - sy = -y - ex = x + cur_object.size.width - ey = -(y + cur_object.size.height) + sx = cur_object.coordinates.x * scaling + offset[0] + sy = ( + self.tiled_map.map_size.height * self.tiled_map.tile_size[1] + - cur_object.coordinates.y + ) * scaling + offset[1] + + ex = sx + cur_object.size.width * scaling + ey = sy - cur_object.size.height * scaling p1 = [sx, sy] p2 = [ex, sy] diff --git a/tests/unit/tilemap/test_tilemap_objects.py b/tests/unit/tilemap/test_tilemap_objects.py index 38853ce9d..413514f2e 100644 --- a/tests/unit/tilemap/test_tilemap_objects.py +++ b/tests/unit/tilemap/test_tilemap_objects.py @@ -1,3 +1,4 @@ +from math import isclose import arcade from pytiled_parser.common_types import Color @@ -34,6 +35,12 @@ def test_one(): assert sprite_1.properties["class"] == "crate" assert sprite_1.properties["name"] == "crate1" + assert "Shapes" in tile_map.object_lists + rectangle = tile_map.object_lists["Shapes"][0] + assert isclose(rectangle.shape[2][0] - rectangle.shape[0][0], 573.60, abs_tol=0.02) + assert isclose(rectangle.shape[0][1] - rectangle.shape[2][1], 469.04, abs_tol=0.02) + assert isclose(tile_map.tiled_map.map_size.height * tile_map.tiled_map.tile_size[1] - rectangle.shape[0][1], 630.37, abs_tol=0.02) + # # # # Test getting layer in group # #