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:
parent
f85622b7e9
commit
882da7de28
1 changed files with 1 additions and 34 deletions
|
@ -173,40 +173,7 @@ std::string UtilityClass::number( int _t )
|
|||
|
||||
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
|
||||
{
|
||||
int leftA, leftB;
|
||||
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;
|
||||
return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
|
||||
}
|
||||
|
||||
void UtilityClass::updateglow()
|
||||
|
|
Loading…
Reference in a new issue