Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1.  
  2. bool colisao(SDL_Rect pRetangulo1, SDL_Rect pRetangulo2){
  3.  
  4.     int vEsquerdo1;
  5.     int vEsquerdo2;
  6.     int vDireito1;
  7.     int vDireito2;
  8.     int vTopo1;
  9.     int vTopo2;
  10.     int vRodape1;
  11.     int vRodape2;
  12.  
  13.     vEsquerdo1 = pRetangulo1.x;
  14.     vDireito1 = pRetangulo1.x + pRetangulo1.w;
  15.     vTopo1 = pRetangulo1.y;
  16.     vRodape1 = pRetangulo1.y + pRetangulo1.h;
  17.  
  18.     vEsquerdo2 = pRetangulo2.x;
  19.     vDireito2 = pRetangulo2.x + pRetangulo2.w;
  20.     vTopo2 = pRetangulo2.y;
  21.     vRodape2 = pRetangulo2.y + pRetangulo2.h;
  22.  
  23.     if (vRodape1 <= vTopo2) return false;
  24.     if (vTopo1 >= vRodape2) return false;
  25.     if (vDireito1 <= vEsquerdo2) return false;
  26.     if (vEsquerdo1 >= vDireito2) return false;
  27.  
  28.     return true;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement