Jump to content
  • Advertisement
Sign in to follow this  

Pixel Perfect Collision

This topic is 4675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to do collision with some stick figures (sad graphics, but least I can make them myself), and the only way I can think of is to use pixel perfect collision. I have no idea how to use this, and I have searched for tutorials on this site, most of them did not really cover it enough and I did not understand them enough to be able to implement them in my game. So can anyone help me and link me a tutorial or even suggest a better method of collision? Edit: I am using c++ with SDL in 2d [Edited by - Salvinger on July 31, 2005 9:20:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
I am assuming this is 2D. If they are truely stick figures, why not just use line collisions for each piece of the body? If you use bullets, it could be a simple ray/line collision (ad ray/circle collision for the head). Seems to be the easiest way and it should be too computationally expenise. Just do a box test for the whole stick figure before looping through all the lines. An added benefit is you know exactly which part the bullet (or whatever) hit and you can add some nice blood effects...

Share this post


Link to post
Share on other sites
Well, the pictures I am using are not true stick figures, I have added some things to them so it would be much harder to use this way. This is why I need the perfect collision.

Share this post


Link to post
Share on other sites
So what do they look like now? Can you define lines to outline whatever you added to the stickfigures, and then do line intersection tests?

Share this post


Link to post
Share on other sites
That would actually work for me, but I have no idea how to do that. I could figure out how to do line intersection, but how could I draw lines around my stick figure? How would the program know where to draw the lines?

Share this post


Link to post
Share on other sites
well in your bitmaps for the figures draw a box around the figure in a color that wont be drawn on screen when you blit. then to test collision you get the coordinates of the box and compare to the other bounding box that may have collided with it. if they touch or overlap then a collison has occured.

Share this post


Link to post
Share on other sites
that article is interesting indeed but I was unable to find any implementation exaples and have no idea where to start and how to code such technique.

since i'm intrested in pixel perfect collision as well can someone please point some pleace or give an exaple how to do it? my best guess is that i need to use BitBlt function with some compare argument.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!