I'm currently creating an android java game. A kind of lunar lander type game. I wish to implement some kind of obstacles, and have gone for asteroids that will be randomly placed on screen.
However, I am struggling to understand how about doing collision detection for these. I will be using images for the asteroids, so could easily use a rectangular bounding box for each image, but as asteroids are circular (or at least mine will be!), a collision could be detected when moving just over the corner of the rectangle, that isn't visually part of the asteroid.
I'm guessing I need to use some sort of bounding circles, but not really sure how I could set this up with images?
I guess, if all the asteroids were the same size, I could hardcode some points for a circular/polygon bounding box and then translate these to the position of the images - so in effect, the polygon is the shape of the asteroid?
Any suggestions on the best method of doing this would be great. Additionally, if someone could whip up some high level collision detection pseudocode, that would be appreciated :)
collision = distance(c1.center,c2.center) < c1.radius+c2.radius
. – A. Rodas