1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Use SDL_HasIntersection for UtilityClass::intersects

This commit is contained in:
Marvin Scholz 2020-01-12 15:09:20 +01:00 committed by Ethan Lee
parent f85622b7e9
commit 882da7de28

View file

@ -173,40 +173,7 @@ std::string UtilityClass::number( int _t )
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B ) bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
{ {
int leftA, leftB; return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
int rightA, rightB;
int topA, topB;
int bottomA, bottomB;
//Calculate the sides of rect A
leftA = A.x;
rightA = A.x + A.w;
topA = A.y;
bottomA = A.y + A.h;
//Calculate the sides of rect B
leftB = B.x;
rightB = B.x + B.w;
topB = B.y;
bottomB = B.y + B.h;
if( bottomA <= topB )
{
return false;
}
if( topA >= bottomB )
{
return false;
}
if( rightA <= leftB )
{
return false;
}
if( leftA >= rightB )
{
return false;
}
//If none of the sides from A are outside B return true; }
return true;
} }
void UtilityClass::updateglow() void UtilityClass::updateglow()