int TestCollision(SDL_Rect a, SDL_Rect b){
int Aleft = a.x;
int Aright = a.x + a.w;
int Atop = a.y;
int Abottom = a.y+a.h;
int Bleft = b.x;
int Bright = b.x + b.w;
int Btop = b.y;
int Bbottom = b.y+b.h;
bool bottom = Abottom < Bbottom;
bool top = Atop > Btop;
bool left = Aright > Bleft;
bool right = Aleft < Bright;
if((left && top) || (left && bottom))
return 2;
if((right && top) || (right && bottom))
return 1;
if((top && left) || (top && right))
return 3;
if((bottom && left) || (bottom && right))
return 4;
return 0;
}
thanks for reading