Skip to content

Correct coordinate calculation for rectangle #1741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2023

Conversation

vanicat
Copy link
Contributor

@vanicat vanicat commented Apr 30, 2023

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
Member

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

Copy link
Contributor

@gran4 gran4 left a comment

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
Copy link
Contributor Author

vanicat commented May 1, 2023

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
Copy link
Contributor Author

vanicat commented May 2, 2023

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