In my XNA program, I am trying to swing a sword. The sword starts at an angle of 180 degrees, then rotates (clockwise) to an angle of 90 degrees.
The Rectangle struct that XNA provides,
Rectangle mAttackBox = new Rectangle(int x, int y, int width, int height);
However, this struct has two problems:
- Holds position and size in Integers, not Floats
- Cannot be rotated
I was hoping someone could help me in either telling me that i'm wrong and the Rectangle can be used for both these methods, or can lead me down the right path for rotating a rectangle.
I know how to create a Struct. I believe that I can make methods like classes. I can determine the 4 vertices of a 2D rectangle by calculating out the x,y of the other 3 given the length, width. I'm sure theres a Matrix class I can use to multiply each point against a Rotation matrix.
But once i have my 4 vertices, I got two other problems: - How do I test other rectangles against it? How does .Intersects() work for the rectangle struct? - Is this even the fastest way to do it? I'd be constantly doing matrix multiplication, wouldnt that slow things down?