title: How to make the player's image in front of another image?
body: <p>I have this code that runs fine but the only problem is that the player's image is behind the other images so you can't see where the player is. How do I make it so the player's image is in front of that image like a background layer. And how do I also make other images appear behind the other background images. Like for example I have this background tree:</p>
  
  <pre><code>class Tree(pygame.sprite.Sprite):
      def __init__(self):
          pygame.sprite.Sprite.__init__(self)
  
          self.image = pygame.image.load('tree.png')
  
          self.rect = self.image.get_rect()
  </code></pre>
  
  <p>And I have the player's class:</p>
  
  <pre><code>class Player(pygame.sprite.Sprite):
      change_x = 0
      change_y = 0
      def __init__(self, x, y):
          pygame.sprite.Sprite.__init__(self)
  
          self.image = pygame.image.load('mapMover.png')
  
          self.rect = self.image.get_rect()
          self.rect.x = x
          self.rect.y = y
  
      def changespeed_x(self,x):
          self.change_x = x
  
      def changespeed_y(self,y):
          self.change_y = y
  
      def update(self, barrier_list, Upcar_list, Downcar_list):
          self.rect.x += self.change_x
  
          barrier_hit_list = pygame.sprite.spritecollide(self, barrier_list, False)
          Upcar_hit_list = pygame.sprite.spritecollide(self, Upcar_list, False)
          Downcar_hit_list = pygame.sprite.spritecollide(self, Downcar_list, False)
  
          for barrier in barrier_hit_list:
              if self.change_x &gt; 0:
                  self.rect.right = barrier.rect.left
              else:
                  self.rect.left = barrier.rect.right
  
          for Upcar in Upcar_hit_list:
              if self.change_x &gt; 0:
                  self.rect.right = Upcar.rect.left
                  Upcar.rect.x += 3
              else:
                  self.rect.left = Upcar.rect.right
                  Upcar.rect.x -= 3
              return
  
          for Downcar in Downcar_hit_list:
              if self.change_x &gt; 0:
                  self.rect.right = Downcar.rect.left
                  Downcar.rect.x += 3
              else:
                  self.rect.left = Downcar.rect.right
                  Downcar.rect.x -= 3
              return
  
          self.rect.y += self.change_y
  
          barrier_hit_list = pygame.sprite.spritecollide(self, barrier_list, False)
          Upcar_hit_list = pygame.sprite.spritecollide(self, Upcar_list, False)
          Downcar_hit_list = pygame.sprite.spritecollide(self, Downcar_list, False)
  
          for barrier in barrier_hit_list:
              if self.change_y &gt; 0:
                  self.rect.bottom = barrier.rect.top
              else:
                  self.rect.top = barrier.rect.bottom
  
          for Upcar in Upcar_hit_list:
              if self.change_y &gt; 0:
                  self.rect.top = Upcar.rect.bottom
                  Upcar.rect.y += 3
              else:
                  self.rect.bottom = Upcar.rect.top
                  Upcar.rect.x -= 3
              return
  
          for Downcar in Downcar_hit_list:
              if self.change_y &gt; 0:
                  self.rect.top = Downcar.rect.bottom
                  Downcar.rect.y += 3
              else:
                  self.rect.bottom = Downcar.rect.top
                  Downcar.rect.x -= 3
              return
  </code></pre>
  
  <p>Python 2.6, Pygame Sprites, Windows 7</p>