-
Notifications
You must be signed in to change notification settings - Fork 110
Description
While refactoring my sokoban game to use this crate instead of my old fork, i realized a friction point that could be worked on.
Previously, to obtain an object's width or height, we could do the following:
object.width
object.height
However, since these members referred to deprecated members within the <object>
tag, they were later removed. This means that to obtain the width/height of an object now, we need to match on the object's shape, check that it is an ellipse or rect, and obtain the width and height from there, something akin to:
let (width, height) = match object.shape {
tiled::ObjectShape::Rect { width, height } | tiled::ObjectShape::Ellipse { width, height } => (width, height),
_ => panic!(),
};
Doing this every time the user wants to obtain width/height of an object is a bit painful (and in this case also panics if the shape is anything but a rect or ellipse), so I propose a object.global_bounds()
function of sorts that returns a rect including the position of the object as well as its actual width/height. I mean actual because previously width/height was not set for polygonal objects (since they are exclusively rect/ellipse members), but it could be useful to calculate them from the min/max point positions of the polygon.