- Splat
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
2D Colission, any thoughts?
I know that you could simply test if the 2 bitmaps(and by this I mean squares with irregular "figures" in them) are overlapping each other.
But that won't look so good..
Maybe one could put many rectangels in each bitmap and test all of them... that would look better...
But is there not a better way of doing this?
Maybe check every pixel? This doesn't sound that fast though..
Hmm any thoughts? How do "real" programmers do in public games?
comments: I'm using DirectX 7.0 and C++. Blitting the sprites to the screen.. Perhaps there is a built in function in the blitter ior Dx?
Mmm and well I would be very happy for some code too
Thanks!
Not clear ? Example ->
Suppose you have a 32x32 sprite.
You can build an array of 32 DWORD, each dword containing the mask for one line of ur sprite. (Bit 31 = 1 if pixel 0 not color key, etc ... ) Ok ?
No supposing you have 2 representations of this sprites, S1 at (X1,Y) , S2 at (X2,Y)
and X2-X1<32 (so the boxes collide !)
we set DX=X2-X1;
then for each row of the sprites :
{
A = MASK_S1[ROW] & (MASK_S2[ROW]<< DX)
if (A != null) then collide
}
This is just what i do to test my sprite collision, and it works fine
Doing it in ASM is easy, and you can modify the algo to work with sprites >32 pixels width...
Hope it helps you ..
Tchaoo.......Zargoun!
[This message has been edited by Zargoun (edited November 10, 1999).]