1

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
A.Snow
  • 21
  • 1
  • 2
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your MCVE code and accurately describe the problem. We should be able to paste your posted code into a text file and reproduce the problem you described. – Prune Oct 30 '18 at 20:52

0 Answers0