Jump to content
  • Advertisement


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


collision detection help?

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

Ok, what I''m trying to do is get some kind of collision detection between a box and a RGB color. I just need something that will check to see if the box is colliding with a certain color in 16 bit. Also, it is DirectX that I''m using and yes it is 2D. So if anyone could please help me I would really appreciate it. Thanks. Krusty95

Share this post

Link to post
Share on other sites
just lock your surface, and then go through the pixels in the box, and check to see if they are the correct color.

Share this post

Link to post
Share on other sites
Will there be alot of these color pixels, or not too many?

if there is not too many, it would be a waste of time to search every pixel on the sceen. What you could do, is every time you plot a pixel of the color you want to check, you store the location in an array, and then when you want to check, you step through the array 1 by 1 and check. You will need to store the x and y of the colored pixel.

Another thought is make a bool array,
e.g. bool bColideColor[screen_width*screen_height];

than when you plot a pixel that special colored pixel, you change the value in the array that you want.

int plot_location = x+(y*lpitch>>1);

if ((dest_buffer[plot_location] = color) == special color)
bColideColor[plot_location] = true;

then when its time to check, just check the value of the bColideColor[x+(y*lpitch)] that you want to check.

That should work, and it will save you from having to check the video memory. But which one you should use if you want would depend on the amount of special pixles that you have.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!