title: python pygame coordinate 0,0 is not in the top left of window
body: <p>I am making a game through the pygame module and I wanted to make a skeleton walk left and right on the window but be stopped by the window &quot;borders&quot; (the left and right side of the screen). This should be 0 on the x coordinate (left) and 1800 on the right coordinate (right).</p>
  <p>However, the 0 coordinate, when printed was not on the left border of the window but rather shifted right and the x coordinate on the left window border was approximately -125. I don't know why the 0 coordinate was shifted right and would like it to be returned to normal.</p>
  <p>Here is the code:</p>
  <pre><code>import pygame
  import os
  pygame.init()
  
  WIDTH, HEIGHT = 1800, 1000
  WIN = pygame.display.set_mode((WIDTH, HEIGHT))
  pygame.display.set_caption(&quot;Animation in Act&quot;)
  
  WHITE = (255, 255, 255)
  BLACK = (0, 0, 0)
  
  FPS = 60
  VEL = 5
  
  SKELETON_WIDTH, SKELETON_HEIGHT = 330, 330
  
  direction_right = False
  direction_left = False
  
  isJump = False
  jumpCount = 10
  
  walkCount = 0
  
  
  SKELETON_RIGHT_START = pygame.transform.scale(pygame.image.load(os.path.join(&quot;Assets&quot;, &quot;pixil-frame-0.png&quot;)), (SKELETON_WIDTH, SKELETON_HEIGHT))
  SKELETON_RIGHT_MIDDLE = pygame.transform.scale(pygame.image.load(os.path.join(&quot;Assets&quot;, &quot;pixil-frame-1.png&quot;)), (SKELETON_WIDTH, SKELETON_HEIGHT))
  SKELETON_RIGHT_END = pygame.transform.scale(pygame.image.load(os.path.join(&quot;Assets&quot;, &quot;pixil-frame-2.png&quot;)), (SKELETON_WIDTH, SKELETON_HEIGHT))
  
  SKELETON_LEFT_START = pygame.transform.flip(SKELETON_RIGHT_START, True, False)
  SKELETON_LEFT_MIDDLE = pygame.transform.flip(SKELETON_RIGHT_MIDDLE, True, False)
  SKELETON_LEFT_END = pygame.transform.flip(SKELETON_RIGHT_END, True, False)
  
  walkRight = [SKELETON_RIGHT_START, SKELETON_RIGHT_MIDDLE, SKELETON_RIGHT_END]
  walkLeft = [SKELETON_LEFT_START, SKELETON_LEFT_MIDDLE, SKELETON_LEFT_END]
  
  
  def draw_window(skeleton):
      WIN.fill(WHITE)
      WIN.blit(SKELETON_RIGHT_START, (skeleton.x, skeleton.y))
  
      pygame.display.update()
  
  
  def handle_skeleton_movement(keys_pressed, skeleton):
      global direction_right, direction_left, isJump, walkCount
  
      if keys_pressed[pygame.K_a] and skeleton.x - VEL + (skeleton.width // 3) &gt; 0:
          skeleton.x -= VEL
          direction_left = True
          direction_right = False
      elif keys_pressed[pygame.K_d] and skeleton.x + VEL + 200 &lt; WIDTH:
          skeleton.x += VEL
          direction_left = False
          direction_right = True
      elif skeleton.x &lt; WIDTH // 2:
          direction_left = False
          direction_right = True
      elif skeleton.x &gt; WIDTH // 2:
          direction_left = True
          direction_right = False
  
      if not isJump:
          if keys_pressed[pygame.K_SPACE]:
              isJump = True
              walkCount = 0
  
  
  def main():
      skeleton = pygame.Rect(0, 600, SKELETON_WIDTH, SKELETON_HEIGHT)
  
      clock = pygame.time.Clock()
      run = True
      while run:
          clock.tick(FPS)
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  run = False
                  pygame.quit()
  
          keys_pressed = pygame.key.get_pressed()
          handle_skeleton_movement(keys_pressed, skeleton)
          print(skeleton.x, skeleton.y)
  
          draw_window(skeleton)
  main()
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/dVD6K.jpg" rel="nofollow noreferrer">enter image description here</a></p>