2D collision testing

Hi
i am making an 2D game and i need to implement collision testing. (not
only box testing) Can u give me some advice? Just kick me in. Thanks for
help.
Jan Kratochvil

Quick and nasty:

XOR the sprites (without background) then memcmp the images.

If there’s a change, there’s been a collision, otherwise, no.

Mark ‘Nurgle’ Collins
Developer Support - Codeplay Ltd.
http://www.codeplay.com–
Mark ‘Nurgle’ Collins
Developer Support - Codeplay Ltd.
http://www.codeplay.com
"Jan Kratochvil" wrote in message
news:9kqptu$sck$1 at ftp.lokigames.com

Hi
i am making an 2D game and i need to implement collision testing. (not
only box testing) Can u give me some advice? Just kick me in. Thanks for
help.
Jan Kratochvil

Note: This would assume that the transparent areas have a pixel value of
zero. (Black, if it’s on RGB format, index 0 if it’s an 8 bit
indexed color format.)

Now, if that’s to much brute force for you (ie if you need to do lots
of collission detection every frame), you could create "collision maps"
for the sprites, with only one bit per pixel. The most complicated part
of that is probably getting the shifting right. (IIRC, SGE does this, so
you can just use that if you don’t feel like reimplementing it yourself.
It could be a good excercise coding it, though. :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Wednesday 08 August 2001 11:59, Mark Collins wrote:

Quick and nasty:

XOR the sprites (without background) then memcmp the images.

If there’s a change, there’s been a collision, otherwise, no.