I'm making a simple allegro game and I need to detect the collision between two bitmaps. I tried to use the bounding box method, but, since my two sprites aren't squares nor rectangles, it is pretty unaccurate. Searching around for a solution, I found the so-called pixel perfect method and it is implementable in Allegro 4 with the PMASK library but not in Allegro 5. Searching around I found this library which does work with Allegro 5, but it's not fully optimised so the collision detection is not precise. Does someone know how to use this system with Allegro 5 or where I can find a completely working library?
you can do it yourself by first checking bounding box then double checking by normalizing the coordinates and using getpixel to see if the normalized coordinate of both bitmaps is non-transparent, for each pixel on one of your bitmaps (or you could be more clever, and only for the pixels in the overlapping sub-region of both bitmaps).
something like
i used a4 where getpixel returns bitmap_mask_color(bmp) for transparent and -1 if the coordinates are outside of the bitmap, but for a5 not sure on that part
thanks a lot it works perfectly