text: import pygame, sys
  from pygame.locals import *
  import random, time # now also importing time for timer functions
   
  ### GAME SETUP ###############
  pygame.init()
  
  #Setting up FPS 
  
  FramePerSec = pygame.time.Clock()
  
  # Game constants
  GAME_NAME = "Dodge The Enemy"
  FPS = 60
  RED   = (255, 0, 0)
  BLACK = (0, 0, 0)
  WHITE = (255, 255, 255)
   
  SCREEN_WIDTH = 400
  SCREEN_HEIGHT = 600
  SPEED = 5
  SCORE = 0
  
  class Enemy(pygame.sprite.Sprite):
        def __init__(self):
          super().__init__() 
          self.image = pygame.image.load("images/alien.png")
          self.surf = pygame.Surface((42, 70))
          self.rect = self.surf.get_rect(center = (random.randint(40,SCREEN_WIDTH-40)
                                                   , 0))
   
        def move(self):
          global SCORE
          self.rect.move_ip(0,SPEED)
          if (self.rect.top > 600):
              SCORE += 1
              self.rect.top = 0
              self.rect.center = (random.randint(40, SCREEN_WIDTH - 40), 0)
   
   
  class Player(pygame.sprite.Sprite):
      def __init__(self):
          super().__init__() 
          self.image = pygame.image.load("images/rocket.png")
          #self.surf = pygame.Surface((40, 75))
          self.rect = self.image.get_rect(center = (160, 520))
          
      def move(self):
          pressed_keys = pygame.key.get_pressed()
          if self.rect.left > 0:
                if pressed_keys[K_LEFT]:
                    self.rect.move_ip(-5, 0)
          if self.rect.right < SCREEN_WIDTH:        
                if pressed_keys[K_RIGHT]:
                    self.rect.move_ip(5, 0)
  
  ### GAME STARTUP ################
  # Create a white screen 
  DISPLAYSURF = pygame.display.set_mode((400,600))
  DISPLAYSURF.fill(WHITE)
  pygame.display.set_caption(GAME_NAME)
  
  # Create FPS object
  FramePerSec = pygame.time.Clock()
  
  # Create and define Fonts
  font = pygame.font.SysFont("Verdana", 60)
  font_small = pygame.font.SysFont("Verdana", 20)
  game_over = font.render("Game Over", True, BLACK)
  background = pygame.image.load("images/background.jpg")
  
  # Create Sprites
  P1 = Player()
  E1 = Enemy()
   
  # Create Sprites groups
  enemies = pygame.sprite.Group()
  enemies.add(E1)
  all_sprites = pygame.sprite.Group()
  all_sprites.add(P1)
  all_sprites.add(E1)
   
  # Create new User event 
  INC_SPEED = pygame.USEREVENT + 1
  pygame.time.set_timer(INC_SPEED, 1000)
  
  MORE_ENEMIES = pygame.USEREVENT + 2
  pygame.time.set_timer(MORE_ENEMIES, 5000)
  
   
  ### GAME LOOP ###############
  while True:     
      for event in pygame.event.get():
          if event.type == INC_SPEED:
              SPEED += 0.1   
          if event.type == MORE_ENEMIES:
              new_enemy = Enemy()
              enemies.add(new_enemy)
              all_sprites.add(new_enemy)
          if event.type == QUIT:
              pygame.quit()
              sys.exit()
   
      # Refresh screen and score
      DISPLAYSURF.blit(background, (0,0))
      scores = font_small.render(str(SCORE), True, BLACK)
      DISPLAYSURF.blit(scores, (10,10))
   
      # Update spite groups
      for entity in all_sprites:
          DISPLAYSURF.blit(entity.image, entity.rect)
          entity.move()
   
      # Detect collision
      if pygame.sprite.spritecollideany(P1, enemies):
            # pygame.mixer.Sound('crash.wav').play()
            time.sleep(0.5)
                      
            DISPLAYSURF.fill(BLACK)
            DISPLAYSURF.blit(game_over, (30,250))
             
            pygame.display.update()
            for entity in all_sprites:
                  entity.kill() 
            time.sleep(2)
            pygame.quit()
            sys.exit()        
           
      pygame.display.update()
      FramePerSec.tick(FPS)