I constructed a collision checker for it basing it off another person's code. Now here's the thing, it should technically work. Below is the code
bool checkCollision(BITMAP* spra, BITMAP* sprb, int ax, int ay, int bx, int by)
{
int trns=makecol(255,0,255);
int x,y;
if (spra == NULL || sprb == NULL)
return false;
if (min( ax+(spra->w % 2), bx+(sprb->w % 2) )<=max(ax-(spra->w % 2),bx-(sprb->w % 2) )
||min( ay+(spra->h % 2), by+(sprb->h % 2) )<=max(ay-(spra->h % 2),by-(sprb->h % 2) ) )
return false;
for(x=max(ax-(spra->w % 2),bx-(sprb->w % 2) );x<min( ax+(spra->w % 2), bx+(sprb->w % 2) );x++)
{
for(y=max(ay-(spra->h % 2),by-(sprb->h % 2) );y<min( ay+(spra->h % 2), by+(sprb->h % 2) );y++)
{
if (getpixel(spra,x-ax,y-ay) != trns && getpixel(sprb,x-bx,y-by) != trns)
return true;
}
}
return false;
}
Now I've looked over the code and I can't work it out. I know that the sprites exist. If anyone can help me fix this I'd appreciate it.
EDIT: Almost forgot
ax,ay = Object A's co-ordinates
bx,by = Object B's co-ordinates
trns = Magenta (Transparency)
This is meant to be perfect pixel collision (box bounding doesnt suit me)
The % keeps the division integers