So as I’ve been using XNA more and more, one thing really bothers me. X and Y can only be ints, which sucks when you want to use Vectors for character position, but want the intersection method of a rectangle.
So my question is what exactly happens in the Rectangle struct?
I’m probably over thinking this all, but thanks for any input in advance.
XNA’s lack of a 2D Axis-Aligned Bounding Box structure (that uses floating-point, unlike
Rectangle) is slightly annoying. It has a 3D one,BoundingBox, which you can re-use if you simply ignore the Z axis.Personally I write my own
AABBstructure and use that. Or, rather, I wrote it once, and it just gets copied between projects. It is not a difficult structure to write.I’d post it for you here, except that you’ve asked specifically how
Rectangleworks (my own structure operates quite differently). So here’s one that I just threw together that should be similar toRectangle:Being something that I just threw together, it’s not exactly well tested. And I’m not sure it will respond the same way as
Rectanglewhen given negative widths/heights. But, as you can see, it’s not much code – so it should be fairly easy to modify.