title: How to prevent the position of the player to go outside screen bounds with pygame?
body: <p>I want to grab the screen width of the x position. So, when I change the screen size I can have it where it already is configuration to the screen size and the player doesn't run off the screen. If that makes any sense. </p>
  
  <pre class="lang-py prettyprint-override"><code>windows = pygame.display.set_mode((1200,1000))
  
  if player_x &gt; pygame.display.get_surface().x-15:
      player_x = pygame.display.get_surface().x-15
  </code></pre>
  
  <p>This isn't right because it crashes the game now.</p>