   Lazyfoo Tutorial Question
  Hey Guys,   I have a quick question regarding LazyFoo's SDL tutorial #19 if anyone has gone through this before.http://lazyfoo.net/SDL_tutorials/lesson19/index.php   Basically, in the following line...//If no sides from vertical A are outside of B   if( ( ( bottomAv <= topB ) || ( topAv >= bottomB ) || ( rightAv <= leftB ) || ( leftAv >= rightB ) ) == false )   {  //A collision is detected  return true;   }  ...lazyFoo describes how to calculate whether a circular object has collided with a rectangular object.  Works great and makes sense to me, but, is there a reason why he used the "== false" line in his if statement?  Couldn't he have just flipped the greater thans to less thans and vice versa?  Maybe I'm missing something huge here.[/source]   
Quote:is there a reason why he used the "== false" line in his if statement?Not really; I wouldn't have written it that way.Another way to negate the whole thing is to just put a '!' in front:if( !( ( bottomAv <= topB ) || ( topAv >= bottomB ) || ( rightAv <= leftB ) || ( leftAv >= rightB ) ) )//  ^ there, so that it refers to the entire conditionQuote:Couldn't he have just flipped the greater thans to less thans and vice versa?You would also have to change the ||'s to &&'s.   ;Quote:Original post by ZahlmanQuote:is there a reason why he used the "== false" line in his if statement?Not really; I wouldn't have written it that way.Another way to negate the whole thing is to just put a '!' in front:if( !( ( bottomAv <= topB ) || ( topAv >= bottomB ) || ( rightAv <= leftB ) || ( leftAv >= rightB ) ) )//  ^ there, so that it refers to the entire conditionQuote:Couldn't he have just flipped the greater thans to less thans and vice versa?You would also have to change the ||'s to &&'s. I see.  The logical not operator definitely makes it look cleaner.  I'm going to use your method instead.  Thanks for the tip.