title: Pygame function won't return True on colliderect
body: <p>I am attempting to create a working jumping system in Pygame, but I'm having some issues with collision detection. I have a level stored in a list like this:</p>
  
  <pre><code>level = [
  "WWWWWWWWWWWWWWWWWWWW",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "W                  W",
  "WWWWWWWWWWWWWWWWWWWW",
   ]
  x = y = 0
  for row in level:
      for col in row:
          if col == "W":
               Wall((x, y))
          x += 32
      y += 32
      x = 0
  </code></pre>
  
  <p>Where each Wall is appended to a list and given a position based on its location in the grid.</p>
  
  <p>This is the wall class:</p>
  
  <pre><code>class Wall (pygame.sprite.Sprite):
      def __init__(self,pos):
          pygame.sprite.Sprite.__init__(self)
          walls.append(self)
           self.rect = pygame.Rect(pos[0],pos[1],32,32)
  </code></pre>
  
  <p>I attempt to move the player rect 30 pixels up when the Up key is pressed and collision between the player and one of the tiles is detected:</p>
  
  <pre><code>if event.type == KEYDOWN and event.key == K_UP:
              if player.hitCheck():
                  player.move(0,-30)
  </code></pre>
  
  <p>hitCheck(), a function of the Player class, looks like this:</p>
  
  <pre><code>def hitCheck(self):
      for wall in walls:
          if self.rect.colliderect(wall.rect):
              return True
  </code></pre>
  
  <p>However, the function never returns True, regardless of any actual collision. I am able to move the player rect without clipping through walls by setting the value of the colliding player-side to the value of the opposite wall-side in question, yet this yields no result.</p>
  
  <p>Why isn't the function returning True on collision?</p>
  
  <p>walls is declared as an empty list initially. It's used in the movement function which is part of the player class as such:</p>
  
  <pre><code>def move_single_axis(self, dx, dy):
      # Move the rect
      self.rect.x += dx
      self.rect.y += dy
  
      for wall in walls:
          if self.rect.colliderect(wall.rect):
              if dx &gt; 0: # Moving right; Hit the left side of the wall
                  self.rect.right = wall.rect.left
              if dx &lt; 0: # Moving left; Hit the right side of the wall
                  self.rect.left = wall.rect.right
              if dy &gt; 0: # Moving down; Hit the top side of the wall
                  self.rect.bottom = wall.rect.top
              if dy &lt; 0: # Moving up; Hit the bottom side of the wall
                  self.rect.top = wall.rect.bottom
  </code></pre>
  
  <p>This works without issue, which is why I'm having trouble understanding why hitCheck() can't detect collision.</p>