Analyzing Pixels in DX 7 for Collision Detection

Started by
0 comments, last by GameDev.net 24 years, 6 months ago
I am developing a Isometric 2D RPG/Adventure hybrid engine using VB 6.0 and DirectX 7.0 and have a question about collision detection.

I am currently using bounding box collision detection (using the IntersectRect API call) as a first pass detection mechanism, but would like to follow that up with pixel detection.

My first idea is to pass the union RECT returned by the IntersectRect API call to each of the colliding objects and have them 'analyze' their bitmaps to see if they have only transparent pixels in the passed RECT (in my system translating the numbers in the returned RECT to coordinates on the object's bitmap is simple).

While this would work, it would actually take more time when the two objects don't collide than it would if they did (since the method could return false as soon as it identified a non-transparent pixel). On the other hand, the method would only have to analyze the small union RECT - not the entire bitmap - so the performance issue may be inconsequential.

I would appreciate comments on this idea. Also, how do you 'analyze' the properties of a particular pixel on a DirectDraw surface (to determine if it is transparent)?

Advertisement
That sounds like a good method for detection, it would take longer if they didnt collide, but this is only the case if they first had a bounding box collition.
I can't help you with the question about examining the pixels becasue I don't use VB. There should be some help in the examples. Try the one that does the blur.

This topic is closed to new replies.

Advertisement