The boolian function that detects a collision between two SDL_RECT's and returns a bool.
bool collision(SDL_Rect a, SDL_Rect b)
{
if((a.y + a.h) <= b.y)
return false;
if((a.x + a.w) <= b.x)
return false;
if(a.x >= (b.x + b.w))
return false;
if(a.y >= (b.y + b.h))
return false;
return true;
}
No comments:
Post a Comment