collision detection

Posted on 2003-02-27
Medium Priority
Last Modified: 2010-04-07
Hi guys there...I'm actually working on a 2D fighting game ..sort of street fighter..I'm just wondering how can I write the codes for collision detections between the characters? thanks
Question by:singersinger
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Accepted Solution

helmet275 earned 60 total points
ID: 8047119
Possibly trying doing bounding boxes for each frame of animation.  For example for a punch: a bounding box around the fist location of the puncher could be compared against possibly three bounding boxes on the defender.  The defender could have a box for a high attack, mid attack, and low attack.  This methods would allow for different types of reactions.  Of course, each frame of animation would have to have separate bounding boxes.

Author Comment

ID: 8048170
Thank you helmet275...But in fact my game isn't totally 2d..its a simulation of 3d using 2d methods..don't you think that  a pixel collision detection would be a better method?

Expert Comment

ID: 8050604
Even if it is a 3d simulation using 2d methods you would still be detecting collisions in a 2d plane.  Doing a pixel by pixel computation is going to be a lot slower than using a bounding box(or circle). Granted a pixel by pixel method would be more accurate but a trade off with speed needs to be considered.  The faster computers today might be able to run a pixel method without a hitch but an older computer might not.  Boxes would probably fit a human shaped body better than circles and by using either of these methods you can check collisions from both front and back with relative ease.  You might try attaching a pointer to a list of your objects to each frame of animation in order to define the collison regions for each frame.

Expert Comment

ID: 8050749
try looking for this webpage for a more detailed description and implementation:

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question