From 6acbdd7291667c76c072a2aa9d9631a9b7329b76 Mon Sep 17 00:00:00 2001 From: Josh Vera Date: Tue, 26 Dec 2023 21:18:19 -0500 Subject: [PATCH 1/2] add px_offset_x and px_offset_y to to_world --- comfy-ldtk/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comfy-ldtk/src/lib.rs b/comfy-ldtk/src/lib.rs index bd0c238..82798c3 100644 --- a/comfy-ldtk/src/lib.rs +++ b/comfy-ldtk/src/lib.rs @@ -95,8 +95,10 @@ impl LdtkLayerExtensions for LayerInstance { fn px_to_world(&self, position: Vec2) -> Vec2 { let grid = self.grid_size as f32; + let px_offset_x = self.px_total_offset_x as f32; + let px_offset_y = self.px_total_offset_y as f32; - vec2(position.x / grid, self.c_hei as f32 - position.y / grid - 1.0) + vec2((position.x + px_offset_x) / grid, self.c_hei as f32 - (position.y + px_offset_y) / grid - 1.0) } } From 4958d1ed21ede2430d30dfead1b36abd4fe179da Mon Sep 17 00:00:00 2001 From: Josh Vera Date: Tue, 26 Dec 2023 21:29:23 -0500 Subject: [PATCH 2/2] format --- comfy-ldtk/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/comfy-ldtk/src/lib.rs b/comfy-ldtk/src/lib.rs index 82798c3..6e45b9d 100644 --- a/comfy-ldtk/src/lib.rs +++ b/comfy-ldtk/src/lib.rs @@ -98,7 +98,10 @@ impl LdtkLayerExtensions for LayerInstance { let px_offset_x = self.px_total_offset_x as f32; let px_offset_y = self.px_total_offset_y as f32; - vec2((position.x + px_offset_x) / grid, self.c_hei as f32 - (position.y + px_offset_y) / grid - 1.0) + vec2( + (position.x + px_offset_x) / grid, + self.c_hei as f32 - (position.y + px_offset_y) / grid - 1.0, + ) } }