Commits

illume committed 28f0dd3 Merge

Merged in Dreamsorcerer/pygame-rect-intersection2 (pull request #11: Optimise rect intersection)

  • Participants
  • Parent commits 879fabe, 4f65c53

Comments (0)

Files changed (1)

 static int
 DoRectsIntersect (GAME_Rect *A, GAME_Rect *B)
 {
-    return ((A->x >= B->x && A->x < B->x + B->w)  ||
-            (B->x >= A->x && B->x < A->x + A->w)) &&
-        ((A->y >= B->y && A->y < B->y + B->h)	||
-         (B->y >= A->y && B->y < A->y + A->h));
+    //A.topleft < B.bottomright &&
+    //A.bottomright > B.topleft
+    return (A->x < B->x + B->w && A->y < B->y + B->h &&
+            A->x + A->w > B->x && A->y + A->h > B->y);
 }
 
 static PyObject*