So far, only half of my collisions work right now. When I am hitting the roof, it does not work, when I am hitting the left, it also does not work. By does not work, I mean that it teleports my sprite to the opposite side of the platform instead of making me stay where I am. Please Help!! :)
def collision(self,xdiff,ydiff,target):
for i in target:
if pygame.sprite.collide_rect(self, i):
if ydiff>0:
self.rect.bottom=i.rect.top
if xdiff>0:
self.rect.right=i.rect.left
if ydiff < 0 :
self.rect.top = i.rect.bottom
if xdiff <0:
self.rect.left = i.rect.right