![](wink.gif)
![](smile.gif)
quote:
Original post by Junghans
can someone explain me EXACTLY how to do a pixel perfect collision, cause I need it for my Space Invaders like...
I start by checking to see if the rectangles for two sprites overlap. If they do not overlap I return false immediately. If they do overlap I calculate the size of the overlap and where the overlap occurs on each sprite. I locate these rectangles in my off-screen surface that contains all the sprite graphics. Then I loop through each pixel in the overlap area (after locking the sprite surface so that I can directly access the sprite pixels) and compare the pixels. When I find a pixel that is non-background in both sprites, I return true. If no such pixel is found, the loop finishes and returns false. I hope you can find the source code and understand it. If this is too difficult, I did also write a detailed document on the whole process (a long time ago) which I could send you (e-mail me if you want it).
quote:
By the way I choose this solution for the 4 blocs down the screen(you see ?) but I don''t know if it''s the good one...
How to modify a bitmap on a directdrawsurfce during the game ??
To locate the pixel where the bullet hit the block, you may have to add some code to the collision detection code. Instead of simply returning true, maybe return a struct with X and Y. (?)
"All you need to do to learn circular logic is learn circular logic"