import pygame
import random
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
class Block(pygame.sprite.Sprite):
    def __init__(self, color):
        super().__init__() # call the parent class constructor
        self.image = pygame.image.load("timmy.png").convert()
        self.image.set_colorkey(WHITE)
        self.image = pygame.transform.scale(self.image, (20, 15))
        self.rect = self.image.get_rect()
    def update(self): # called each frame
        self.rect.y += 1   # Move block down one pixel  
        if self.rect.y > 410:   # If block is too far down, reset to top of screen.
            self.rect.y = -20 
pygame.init()
screen_width = 700      # Set the height and width of the screen, along with background image
screen_height = 400
screen = pygame.display.set_mode([screen_width, screen_height])
background_image = pygame.image.load("saturn_family1.jpg").convert()
font = pygame.font.SysFont('Calibri', 25, True, False)
all_sprites_list = pygame.sprite.Group()    # This is a list of every sprite. All blocks and the player block as well.
block_list = pygame.sprite.Group()      # List of each block in the game
for i in range(50):     # --- Create the sprites
    block = Block(BLUE)
    block.rect.x = random.randrange(screen_width)
    block.rect.y = random.randrange(150)
    block_list.add(block)
    all_sprites_list.add(block)
done = False
clock = pygame.time.Clock()     # Used to manage how fast the screen updates
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
    all_sprites_list.update()   # Call the update() method on all the sprites so that they all move appropiately
    screen.blit(background_image, [0, 0]) # now clear the screen, so that we can re-add all the stuff  
    all_sprites_list.draw(screen)   # Draw all the sprites
    pygame.display.flip()   # Go ahead and update the screen with what we've drawn.
    clock.tick(20)  # higher the number the faster
pygame.quit()