Skip to content
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

Hitboxes still need work #3

Closed
pvcraven opened this issue May 27, 2019 · 7 comments
Closed

Hitboxes still need work #3

pvcraven opened this issue May 27, 2019 · 7 comments

Comments

@pvcraven
Copy link
Member

Currently, if we have a hitbox defined as a polygon:

   <object id="1" x="128" y="0">
    <polygon points="0,0 -118.364,0.0909091 -127.818,9.54545 -127.818,62.1818 -116.909,73.8182 -0.181818,74.1818"/>
   </object>

pytiled will pull the object info, but not the polygon points.

@benjamin-kirkbride
Copy link
Collaborator

I see that you have added a pull request with some work regarding this, the issue is that I think that a more broad solution is required, as "hitboxes" are really just objects that can be used in other contexts, and also can have properties, a template, a type, opacity, etc.

As such, I have implemented a "TiledObject" class that all of them can inherit from.

@attr.s(auto_attribs=True, kw_only=True)
class TiledObject:
    """
    TiledObject object.

    See:
        https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#object

    Args:
        :id_ (int): Unique ID of the object. Each object that is placed on a
            map gets a unique id. Even if an object was deleted, no object
            gets the same ID.
        :gid (Optional[int]): Global tiled object ID
        :location (OrderedPair): The location of the object in pixels.
        :size (Size): The width of the object in pixels
            (default: (0, 0)).
        :rotation (int): The rotation of the object in degrees clockwise
            (default: 0).
        :opacity (int): The opacity of the object. (default: 255)
        :name (Optional[str]): The name of the object.
        :type (Optional[str]): The type of the object.
        :properties (Properties): The properties of the TiledObject.
        :template Optional[Template]: A reference to a Template object FIXME
    """

    id_: int
    gid: Optional[int] = None

    location: OrderedPair
    size: Size = Size(0, 0)
    rotation: int = 0
    opacity: float = 1

    name: Optional[str] = None
    type: Optional[str] = None

    properties: Optional[Properties] = None
    template: Optional[Template] = None

I am going to move in this direction, hopefully it will work out.

@pvcraven
Copy link
Member Author

So...where are they stored now?

@pvcraven
Copy link
Member Author

I'm confused about the intent here. But we don't seem to be storing the hitboxes anywhere right now, correct?

@benjamin-kirkbride
Copy link
Collaborator

benjamin-kirkbride commented Jul 17, 2019 via email

@pvcraven
Copy link
Member Author

Ok, so the updated PR should do a better job.

@benjamin-kirkbride
Copy link
Collaborator

I am currently doing a major re-work of this, as object parsing is done in two places right now and really should be cleaned up and consolidated

@Cleptomania
Copy link
Member

The new v1.0.0 JSON re-write has 100% coverage of all Tiled object types for this.

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

No branches or pull requests

3 participants