• Advertisement
Sign in to follow this  

Rotated sprite collision detection

This topic is 3189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using directx to program a 2d sprite engine. I have a class which represents an image on the screen called jSprite. This class contains the d3d texture and float values of all the possible transformations. My collision detection function accepts 2 jSprite objects and should return true if any overlap exists between the sprites. So far, I have been using simple bounding rectangles, which work alright with non-rotated sprites. The problem with my current algorithm is that it does not account for the rotation, center of rotation, or scaling factors. I found this article: http://www.gamedev.net/reference/articles/article2604.asp , which would probably work for what I need, but it does not explain how to find the verticies of the rotated rectangles. I was thinking I could find the new points given a transformation matrix and the initial points, but I do not know how to do this. Another thing I was thinking of doing is using bounding circles for all my images, but I would still need a way to account for the rotation around a point other than the center of the sprite. Any help with this would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
google rotation matrices and you'll see how to rotate a point in space. The rotation happens about the centre (0,0). If you want to rotate about a different point in space then you first move your point so that the centre of rotation is at 0,0 then rotate and then move everything back to where it was.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement