title: getting correct player collision
body: <p>I'm making a tile-based plaformer game with pygame. this is my player sprite:</p>
  <p><a href="https://i.stack.imgur.com/zWpov.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zWpov.png" alt="enter image description here" /></a></p>
  <p>this is the collision detector code:</p>
  <pre><code> for tile in world.tile_list:
              # check for collision in x direction
              if tile[1].colliderect(self.rect.x + dx, self.rect.y, self.width, self.height):
                  dx = 0
                  # check for collision in y direction
              if tile[1].colliderect(self.rect.x, self.rect.y + dy, self.width, self.height):
                  # check if below the ground i.e. jumping
                  if self.vel_y &lt; 0:
                      dy = tile[1].bottom - self.rect.top
                      self.vel_y = 0
                  # check if above the ground i.e. falling
                  elif self.vel_y &gt;= 0:
                      dy = tile[1].top - self.rect.bottom
                      self.vel_y = 0
  </code></pre>
  <p>when I run the game as shown in this image: the player can stand outside platforms,
  <a href="https://i.stack.imgur.com/dyBZr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dyBZr.jpg" alt="enter image description here" /></a></p>
  <p>I need to get the correct player width so when I use <code>width = player_png.get_width()</code> I get the total width of this image,  but I just want the width of the first leg to the second leg so that the collision detector will only consider that width as the player width.</p>
  <p><a href="https://i.stack.imgur.com/bP2yd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bP2yd.jpg" alt="enter image description here" /></a></p>
  <p>I can manually assign the width to the width from the first leg to the second leg but when I do that the collision detector detects that width to the middle of the image and doesn't align it correctly</p>