Link to home
Start Free TrialLog in
Avatar of singersinger
singersinger

asked on

collision detection

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
ASKER CERTIFIED SOLUTION
Avatar of helmet275
helmet275

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of singersinger
singersinger

ASKER

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?
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.
try looking for this webpage for a more detailed description and implementation:
http://www.gamedev.net/reference/articles/article735.asp