Archived

This topic is now archived and is closed to further replies.

re: collision detection using pixel colors in side scroller

This topic is 5174 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

Hey, I am writing a 2-dimensional side scroller using DirectX 8.0. For the collision detection, I am currently unable to do anything besides the simple if the 2 boxes surrounding the characters intersect, detect collision...The problem with this method is that the characters have to be drawn to completely fill the box. My question is what is a good method to use to do this? One thing I have heard is that one can read the pixel color and have the program respond accordingly... Any input would be greatly appreciated. Dan

Share this post


Link to post
Share on other sites
Yes, you can test pixel colours in the sprites.

Alternatively, store a collision mask with your sprite - a simple 1 bit/pixel image, where a 1 indicates a solid part. Perform a bitwise AND operation with a second sprite''s collision mask, and any overlapping sections will give you a non-zero result.

Share this post


Link to post
Share on other sites
Ok, so if I do what you are calling a bit-pixel image, i would create another 2d array of the same dimensions as the sprite filled with 1s and 0s. Then I can test for where there are two one?

Sounds great. Now is there a quick way though to create that array from my picture as opposed to doing it manually?

Share this post


Link to post
Share on other sites