locked
A Collision Detection Method. Good or Bad? RRS feed

  • Question

  • I am developing a 2D fighting game so the game consists of a lot of 2D sprite animation. Inorder to detect collision of two fighters, I have decided to implement a pixel based collision detection method. What it does is during inizialization it stores all the pixels of each frame into a set of arrays (one array per sprite frame). Then it does this again with the sprites being flipped horizontal this time arround. Then I just use all these arrays in my collision detection to detect when the two fighters collide.

     

    So I have been wondering if this was a good or bad way of going about collision detection? Will something like this cause long loading times (perhaps due to the initialization of so many arrays)? And will it also slow down the game due to the way collision detection is implemented?

     

    If this is a bad way to go about collision, what other alternatives would you recommend?

     

    Thanks.

    Friday, April 27, 2007 6:22 PM

Answers

  • Well, I use a set of few coordinates of corners of 2D shapes to detect collision. So for a rectangle I would get the coord of the four corners, and if another corner of another rectangle comes in between, which means if both the X and Y of the second corner is within the range of X and Y of the first, then they are overlapping. I think this method should be faster. I think XNA has built in bounding box and collision detection?
    Tuesday, May 1, 2007 12:39 AM

All replies

  • I would recommend that you go to the new Microsoft XNA forums to ask this question. These new Microsoft XNA forums can be found at http://creators.xna.com

    The current forums will be locked down soon and the industry experts who can best answer your question are now monitoring the new forums.

    So just head on over and re-ask your question.

    If you are unable to sign-up at the new forums due to country restrictions, please reply to this thread and we will try and support you the best we can here.

    Thanks!
    Friday, April 27, 2007 7:26 PM
  • Well, I use a set of few coordinates of corners of 2D shapes to detect collision. So for a rectangle I would get the coord of the four corners, and if another corner of another rectangle comes in between, which means if both the X and Y of the second corner is within the range of X and Y of the first, then they are overlapping. I think this method should be faster. I think XNA has built in bounding box and collision detection?
    Tuesday, May 1, 2007 12:39 AM