Skip to content

Expanded objects #189

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

pnearing
Copy link

I expanded TiledObject to recognize ellipses, text and points. I added a new property to the object called object_type which is meant to be a literal string, currently it will be one of "rectangle", "text" "polygon" "polyline", "ellipse", and "point".

Also my IDE cleaned up and made some date changes.

Changed the copyright years in multiple files for consistency. Adjusted object types in `pytmx.py` to include additional types such as ellipse, point, and text, along with their respective attributes. Refined imports and typing hints across various modules for clarity and efficiency.
Changed all single quotes to double quotes for string literals in pytmx.py. This ensures uniformity in the codebase and improves readability and maintainability of the code. No functional changes were made.
@joereynolds
Copy link

Hmm, those changes made by your IDE are a bit suspect

They've changed the copyright years to be in the past. What's worse though is that they've removed the return typehints which are useful for people working with PyTMX

@pnearing
Copy link
Author

I didn't notice the type hint changes. I'll go through them and check it out, I'm all about typing.

Introduce a new method, get_tile_flags_by_gid, to fetch tile flags using the global tile ID (GID). This improves the convenience of accessing tile properties directly by their GID.
@pnearing
Copy link
Author

Okay, I've removed the changes my IDE made, and left only the object changes, also I added a function called get_tile_flags_by_gid to get the flags of a gid, I use this for correctly flipping and rotating my colliders.

Copy link

@zommerfelds zommerfelds left a comment

Choose a reason for hiding this comment

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

Leaving some drive-by comments :)

I was about to make the same changes, so let's try to get this PR in, it's useful!

@zommerfelds
Copy link

zommerfelds commented Apr 13, 2025

BTW I switched to using @pnearing's repo for my project, and it does work.

One thing to note is that images/tiles are considered rectangles. Which is not wrong, as you can use the gid property to distinguish, but we could consider setting the object_type to tile.

@zommerfelds
Copy link

Sorry to add yet another comment, but another thing that would be convenient is if rectangles also had points generated... (future follow-up)
Meanwhile I'll have to manually convert from rectangle to points, so I can draw using the same polygon function.

@pnearing
Copy link
Author

Sorry to add yet another comment, but another thing that would be convenient is if rectangles also had points generated... (future follow-up) Meanwhile I'll have to manually convert from rectangle to points, so I can draw using the same polygon function.

If you happen to still be using my repo, I added points for rectangles.

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.

3 participants