title: How do I set a boundary in which my image can go through in Pygame?How do I keep an image from going behind another?
body: <p>This is the code for my pygame</p>
  
  <pre><code>import pygame
  import os
  
  img_path=os.path.join('C:/Desktop/Python Stuff','Angry Birds.jpg')
  class pic(object):
      def __init__(self):
      """ The constructor of the class """
      self.image = pygame.image.load(img_path)
      # the bird's position
      self.x = 0
      self.y = 0
  
  
  def handle_keys(self):
      """ Handles Keys """
      key = pygame.key.get_pressed()
      dist = 5
      if key[pygame.K_DOWN]: # down key
          self.y += dist # move down
      elif key[pygame.K_UP]: # up key
          self.y -= dist # move up
      if key[pygame.K_RIGHT]: # right key
          self.x += dist # move right
      elif key[pygame.K_LEFT]: # left key
          self.x -= dist # move left
  
  def draw(self, surface):
      """ Draw on surface """
      # blit yourself at your current position
      surface.blit(self.image, (self.x, self.y))
  </code></pre>
  
  <p>This is the screen size. Is this where the I should restrict the image's boundaries?        </p>
  
  <pre><code>pygame.init()
  screen=pygame.display.set_mode([1500,850])
  Pic=pic()
  
  pygame.display.set_caption('Angry Birds')
  </code></pre>
  
  <p>This is the image that I want to have a boundary for</p>
  
  <pre><code>pic=pygame.image.load('Angry Birds.jpg')
  
  keep_going=True
  while keep_going:
      event=pygame.event.poll()
     *emphasized text* if event.type == pygame.QUIT:
      pygame.quit()
      running = False
  Pic.handle_keys()
  screen.blit(pic, (-200, 0))
  Pic.draw(screen)
  </code></pre>
  
  <p>This image is what the 'Angry Birds' image is going behind. How do I stop it from going behind this image? </p>
  
  <pre><code>tux=pygame.image.load('Rock Lee.gif')
  
  
  
  screen.blit(tux,(500,600))
  screen.blit(tux,(500,400))
  screen.blit(tux,(500,0))
  screen.blit(tux,(900,200))
  screen.blit(tux,(900,400))
  screen.blit(tux,(900,600))
  screen.blit(tux,(1300,0))
  screen.blit(tux,(1300,200))
  screen.blit(tux,(1300,600))
  pygame.display.get_surface([1500,850]).get_size([1500,850])
  pygame.display.update()
  </code></pre>