Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

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
0
singersinger
Asked:
singersinger
  • 3
1 Solution
 
helmet275Commented:
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.
0
 
singersingerAuthor Commented:
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?
0
 
helmet275Commented:
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.
0
 
helmet275Commented:
try looking for this webpage for a more detailed description and implementation:
http://www.gamedev.net/reference/articles/article735.asp
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now