This question already has an answer here:
- OBB vs OBB Collision Detection 3 answers
I have a problem with collision detection in a 2D Java game.
Normally, what I would do is create a getBounds() method for an object that can collide with other objects. This method would return a
new Rectangle(x,y,width,height), where
y are the coordinates for the top-left corner of the sprite, and
height are the width and height of the sprite.
But in the game I'm currently working on, there is a "tank" controlled by the user. The sprite of this tank rotates as long as the player holds one of the left or right arrow buttons. In other words, it can rotate to any angle. The tank's sprite is a rectangle.
So I can't simply do what I always do in this case.
How can I detect collision with this kind of sprite? Thanks