Skip to content

Correct coordinate calculation for rectangle - #1741

Merged
pvcraven merged 2 commits into
pythonarcade:developmentfrom
vanicat:patch-1
May 31, 2023
Merged

Correct coordinate calculation for rectangle#1741
pvcraven merged 2 commits into
pythonarcade:developmentfrom
vanicat:patch-1

Conversation

@vanicat

@vanicat vanicat commented Apr 30, 2023

Copy link
Copy Markdown
Contributor

The new computation

  • scale the rectangle as anyother coordinate
  • use self.tiled_map.map_size.height * self.tiled_map.tile_size[1] to offset the y coordinate, otherwise they are negative.

Fix #1740

@pvcraven

Copy link
Copy Markdown
Member

Looks like it didn't pass tests? Please research if you could.

@gran4 gran4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-Add the 2 lines(921 and 922):
x = cur_object.coordinates.x + offset[0]
and
y = cur_object.coordinates.y + offset[1]
You deleted. Without them, x and y don't exist.

@vanicat

vanicat commented May 1, 2023

Copy link
Copy Markdown
Contributor Author

I will look at the test after the end of Ludumdare,

- scale the rectangle as anyother coordinate
- use self.tiled_map.map_size.height * self.tiled_map.tile_size[1] to offset the y coordinate,
otherwise they are negative.
@vanicat

vanicat commented May 2, 2023

Copy link
Copy Markdown
Contributor Author

I've updated the patch, and it now pass all the test.
The two line proposed by gran4 was not correct, because the offset must be apply after the scaling (at least, it is what happen for others coordinate computation).

Thanks.

Some computation are made to translate the coordinate système of tiled
to the one of arcade. Those 3 new test check they are ok.
@einarf
einarf requested a review from Cleptomania May 5, 2023 16:56
@pvcraven
pvcraven merged commit efd98f8 into pythonarcade:development May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rectangle from Tiled are load at the wrong coordinate

3 participants