Archived

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

Krusty95

collision detection help?

Recommended Posts

Krusty95    122
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
Slinger    122
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.
e.g.

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