title: How can I make a scrolling background in python with pygame?
body: <p>I've been trying to make a space shooting game for the past 2 days and I want to make the background scrolling down but i don't know how.
  Heres my code:</p>
  
  <pre><code>import pygame
  import time
  pygame.init()
  
  width = 800
  height = 600
  
  black = (0,0,0)
  white = (255,255,255)
  red = (255,0,0)
  green = (0,255,0)
  blue = (0,0,255)
  
  ship_width = 35
  ship_height = 64
  
  disp = pygame.display.set_mode((width,height))
  
  pygame.display.set_caption("Space Jump")
  
  clock = pygame.time.Clock()
  
  background = pygame.image.load("Space.png").convert()
  
  shipImg = pygame.image.load("Ship.png")
  
  def ship(x,y):
      disp.blit(shipImg, (x,y))
  
  def gameLoop():
      x = (width * 0.45)
      y = (height * 0.8)
  
  x_ch = 0
  y_ch = 0
  
  gameExit = False
  
  while not gameExit:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              gameExit = True
  
          if event.type == pygame.KEYDOWN:
              if event.key == pygame.K_LEFT:
                  x_ch = -5
              elif event.key == pygame.K_RIGHT:
                  x_ch = 5
              elif event.key == pygame.K_UP:
                  y_ch = -5
              elif event.key == pygame.K_DOWN:
                  y_ch = 5
  
  
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                  x_ch = 0
              if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                  y_ch = 0
  
      x += x_ch
      y += y_ch
  
      if x &gt; width - ship_width or x &lt; 0:
          x_ch = 0
  
      if y &gt; height - ship_height or y &lt; 0:
          y_ch = 0
      x_bg = 0
      while True:
          disp.blit(background, (0,x_bg)) # i tried this but when i launch
                                          #a black screen just appears without 
          x_bg -= 1                       #any image
      ship(x,y)
  
      pygame.display.update()
      clock.tick(60)
  
  gameLoop()
  pygame.quit()
  quit()
  </code></pre>
  
  <p>I have a background and i want to make it scrolling down continuously can you help me?</p>