## Calculate collision with rotate()

Problems with Canvas, OpenGL, etc...

### Calculate collision with rotate()

Hi,

I am currently working on a 2D Game with square bitmaps that move over the androidscreen. The corners and edges of the bitmaps are transparent, in the middle you see a frog . Now I am faced with the collision calculation, so that the frogs must stop after contact with other frogs. But I have a problem to calculate the collision after using the function rotate(). I need rotate(), to turn the frogs to the direction they are looking.
To calculate a collision with horizontal bitmaps is easy:

int firstXRangeStart = x_Coordinate;
int firstXRangeEnd = firstXRangeStart + widthBitmap;

But does somebody know how to perform a collision calculation when bitmaps are not just horizontal, because they are rotated through an angle? At the moment I use always a horizontal BoundingBox. But this is very unexact.

Thank you very much
Duckemai
Duckemai
Freshman

Posts: 4
Joined: Sat Aug 21, 2010 10:13 am

### Re: Calculate collision with rotate()

http://en.wikipedia.org/wiki/Separating_axis_theorem is probably your best bet. You'll need to maintain the bounds of your bitmaps as separate objects, and also rotate them as you rotate your bitmap (ideally you'll have an single GameEntity object which has a single rotate() method, which rotates both its bounds and drawable)

mark@project8games.com
Developer

Posts: 41
Joined: Tue Mar 02, 2010 8:33 pm