Reputation: 13
I've looked at many collision detection technique for a 2D game but I can't find exactly what I'm looking for. My game is a brickbreaker kind of game.
I've looked at pixel to pixel collisions style but it looks complicated for what i'm trying to do. Is there an easier way? I'm using XNA. Thanks in advance.
Upvotes: 1
Views: 1460
Reputation: 2753
Here is the correct way to do it.
For each combination of two sub regions from object A and object B, do the following comparison: a. Construct a skewed prism in N+1 dimensional space. This is the extrusion of the convex subregion as it moved from its location at time=0 to time=n. If the object rotated, you're SOL as this will not be a convex region.
b. Use the Simplex algorithm to determine if there is a feasible intersection of the two convex sub regions. Alternately you could use the ellipsoidal method or an interior traversal LP algorithm.
c. If any of the pairs of convex sub regions intersect, then there is a collision.
... or you can use axis-aligned rectangles like everyone else. If you need to speed them up, use interval trees.
Upvotes: 3
Reputation: 13303
Have you tried looking into Rectangle collisions ?
You declare a Rectangle
on your sprites and check if they Intersect
to test for a collision. It's the easiest way I know.
Look here for explanations on how to use it.
Hope this helps.
Upvotes: 3