title: Pygame - How do I stop a sprite from leaving the edge of the window?
body: <p>I have my window popping up and I can move my sprite around the screen with my arrow keys.  I know there's a collision function with sprite on sprite collision, but I can't seem to figure out how to stop them from moving outside of the visible area.  Any thoughts?</p>
  
  <p>my move function:</p>
  
  <pre><code>def moveme(self,coords)
      #coords=(x,y)
      self.rect.move_ip(coords)
  </code></pre>
  
  <p>for the event handler i'm using something like</p>
  
  <pre><code>keys = pygame.key.get_pressed()
  if keys[pygame.K_UP]:
      character.moveme((0, -4))
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>