Basically, I have a game in which a character drops a balloon. The character is allowed to overlap the balloon when they drop it, but as soon as they move out of the balloon's rect, they shouldn't be able to overlap it (it becomes like a barrier).
for balloon in balloons:
if self.rect.colliderect(balloon.rect):
if d == 'right':
self.rect.right = balloon.rect.left
if d == 'left':
self.rect.left = balloon.rect.right
if d == 'forwards':
self.rect.bottom = balloon.rect.top
if d == 'backwards':
self.rect.top = balloon.rect.bottom
If I have something like this, the character jumps out of the rect of the balloon. I was thinking I need to use some sort of boolean to check whether the overlap is allowed initially, but I'm not sure how to implement that. Any ideas?
Thanks!