Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I recently started making a game in windows phone XNA, I have a rocket in the middle that I can rotate and has a thrust to speed up in the direction it is facing and meteors coming out. The point is to survive as long as you can and avoid collision with the meteors. I can't manage to implement the collision between two moving and rotating sprites which are the rocket and a random meteor. I've seen rectangular collision which to me appears bad but maybe I am coding it a bit wrong and the pixel collision is way complicated :/ any help would be appreciated, thanks in advance :)

share|improve this question
add comment

1 Answer

You're right on that main point: pixel collision is way complicated. Often times, it's going to be far, far more effort than it's worth. You'll likely have to program a form of collision that's not 100% the same as the visuals you draw. A rocket sounds like something that could very easily use rectangle collision detection. However, a random guess suggests the meteors are more circular. Actually, circle collision detection is also pretty basic; for instance, circle-to-circle collision just involves calculating the distance between two objects, and comparing their radii (plural of radius)

This involves a bit of math; I think for the progress of your game development skills, it would be good to try to understand what's happening here, or even look up some textbooks on the subject; but if you get a basic grasp of what goes in and what comes out, you may just be able to drop it into your code...

http://stackoverflow.com/questions/2443845/the-maths-for-2d-collision-detection-between-an-obb-and-a-circle

(Oriented means having some form of rotation. Bounding box is a fancy name for a rectangle.)

share|improve this answer
    
Now that I look at it, I think that code sample in the link may not suit your needs. Someone else links to Wikipedia, and Seperating Axis seems like the correct thing to use - I just haven't worked with collision detection in a while, so I hadn't remembered the name of the correct formula to use for box <-> circle. –  Katana314 May 24 '13 at 18:25
    
can you give me an example of rectangular collision of moving and/or rotating sprites? –  Kanga May 24 '13 at 19:21
    
A few links that may help: xnadevelopment.com/tutorials/rotatedrectanglecollisions/… metanetsoftware.com/technique/tutorialA.html (The second link is what I used for collision detection when I was in college!) A few changes are needed for your specific implementations. –  Katana314 May 25 '13 at 19:56
    
I hope that will help me thank you :) –  Kanga May 25 '13 at 21:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.