1. ## Programming Collision Detection

Anyone here know about collision detection at all? I'm trying to make a program that has objects in it that will rotate around a central fixed point. I need to know how to be able to tell if I'm running in to that object, no matter what angle it's rotated at....

2. ## ~

Bounding box based on the most extreme vertices... just make sure you rotate the bounding box's vertices constant with the way you rotate the object.

3. There are a lot of ways to detect for collisions in 2D. The basic way is to see if the point, or box, is inside a bounding box. This is the fastest method.

You can do it another way, my favorite. You find the center of the sprite (width/2, height/2) and use (width/2) as the radius. That way you have a circle. You get the point in question, find the distance from the cetner point (pythagorean's theorem) and if it's less than or equal to the radius: collision! This is just a bit slower, but it looks A LOT more accurate when you're playing your game.

You can also test for bit-collision between the pictures of the sprites. Just draw their masks on top of each other and see if they collide. Really CPU intensive. It's recommended that you first use a bounding box test. If it's true, then do this, if you want. This is the most accurate test.

If you're using polygons, chances are the library you're using, like DirectX, has collision detection functions. Find them and figure out how to implement them.

If you're using 3D, all this gets just a bit more complicated. You'll have to think in another level....

4. Also, to reduce speed, make collision rules. For example, enemy missiles can't hit enemies. Friendly fire can't happen. Things like along those lines. This reduces the ammount of collision tests you need to perform.

Say you had 5 baddies, 3 bad missiles, you, and your 2 missiles. If you tested everything, you would have (n^2-n) tests, or 110 tests. But if you decided that baddies can't hit each other, you can't get hit from your missiles, and that missiles can't hit each other, you would only have (2 your missiles * 5 baddies + 1 you * 3 baddie missiles), or 13 tests. As you see, the latter will be much faster.

The speed of the collision detection is just half the story, minimizing the number of tests is the other.