def colliderect(self, other): a = self b = other w, h = self.size tl = a.topleft tr = a.topright bl = a.bottomleft br = a.bottomright tl = rotate_point(tl, a.angle, a.center) tr = rotate_point(tr, a.angle, a.center) bl = rotate_point(bl, a.angle, a.center) br = rotate_point(br, a.angle, a.center) for i in [tl, tr, bl, br]: if b.collidepoint(i): return True #only test this if the other fails! w, h = b.size tl = b.topleft tr = b.topright bl = b.bottomleft br = b.bottomright tl = rotate_point(tl, b.angle, b.center) tr = rotate_point(tr, b.angle, b.center) bl = rotate_point(bl, b.angle, b.center) br = rotate_point(br, b.angle, b.center) for i in [tl, tr, bl, br]: if a.collidepoint(i): return True return False
def collidepoint(self, other): other = rotate_point(other, -self.angle, self.center) return Rect.collidepoint(self, other)