简体   繁体   中英

Best 2D collision detection

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.

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.

Here is the correct way to do it.

  1. Tessellate both objects into a set of convex sub regions. This can be done as a pre-processing step.
  2. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM