Sunday, September 16, 2012

Collision Function for SDL/C++

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

How to create Custom push button in QT5

To be honest this is not my work its an exact copy from this link. http://mcmtechtips.blogspot.com/2012/03/shape-qpushbutton-in-your-own-st...