• Advertisement
Sign in to follow this  

2d sprite collision with rotation

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

Im working on a 2d collision detection algorithm for my sprite engine. I've done this in the past with bounding rectangles, but that wont work with rotated sprites. For example, If the sun were in the center of the screen with the Earth rotating around it, my collision detection would always think the Earth is right above the sun because it does not account for rotation. My detection function accepts two custom jSprite classes, which hold information for all the transformations such as radians of rotation and rotation center point. How can I account for these transformations for detecting collisions?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ChainChief
Im working on a 2d collision detection algorithm for my sprite engine. I've done this in the past with bounding rectangles, but that wont work with rotated sprites. For example, If the sun were in the center of the screen with the Earth rotating around it, my collision detection would always think the Earth is right above the sun because it does not account for rotation. My detection function accepts two custom jSprite classes, which hold information for all the transformations such as radians of rotation and rotation center point. How can I account for these transformations for detecting collisions?


First, specify what language and API are you using otherwise giving code example is pretty much useless.
Anyway in DirectX the bounding rectangles aren't actually the best way to manage cause they have "problems" with rotations and such. I suggest switching to the use of bounding spheres and make them take account of the trasformation matrix you are applying to the object.

Share this post


Link to post
Share on other sites
I am using visual c++ 2008 with DirectX. The bounding spheres sounds like it would work well for my engine, but I am not sure how to set this up to take into account the transformations. Can someone send me a link to an explanation of this?

Share this post


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

  • Advertisement