title: Pygame collision between player and block
body: <p>I'm making a game and I want to check collision between player and block, and push back player if neccesary.</p>
  
  <pre><code>def collide(self,player):
      if self.solid:
          if self.rect.colliderect(player.rect):
              if self.rect.bottom-1 &lt;= player.rect.top and player.pos == 'up':
                  player.up = 0
                  player.rect.move(0,1)
              if self.rect.top+1 &gt;= player.rect.bottom and player.pos == 'down':
                  player.down = 0
                  player.rect.move_ip(0,-1)
              if self.rect.left+1 &lt;= player.rect.right and player.pos == 'right':
                  player.right = 0
                  player.rect.move_ip(-1,0)
              if self.rect.right-1 &gt;= player.rect.left and player.pos == 'left':
                  player.left = 0
                  player.rect.move_ip(1,0)
  </code></pre>
  
  <p>but for some reason it doesn't work. Can someone help me?
  Thanks in advance</p>