title: pygame.error:video system not initialized but I already used pygame.init()
body: <p>I checked the question with the same error as myself, but it was an initialization problem. So I made sure I did the initialization
  I used pygame.init() but error occured.I do not understand this.
  so I specify where Pycharm IDE tells me it is in the code below. help me</p>
  <pre><code>import pygame
  import random
  
  BLACK=(0,0,0)
  pad_width=480
  pad_height=640
  fight_width=36
  fight_height=38
  enemy_width=26
  enemy_height=20
  def drawObject(obj,x,y):
      global gamepad
      gamepad.blit(obj,(x,y))
  def runGame():
      global gamepad,clock,fighter,enemy
      x=pad_width*0.45
      y=pad_height*0.9
      x_change=0
      enemy_x=random.randrange(0,pad_width-enemy_width)
      enemy_y=0
      enemy_speed=3
      ongame=False
      while not ongame:
          for event in pygame.event.get():      #I got an error here
              if event.type ==pygame.QUIT:
                  ongame=True
              if event.type==pygame.KEYDOWN:
                  if event.key==pygame.K_LEFT:
                      x_change-=5
                  elif event.key==pygame.K_RIGHT:
                      x_change+=5
              if event.type==pygame.KEYUP:
                  if event.key==pygame.K_LEFT or event.key==pygame.K_RIGHT:
                      x_change=0
          gamepad.fill(BLACK)
  
          x+=x_change
          if x&lt;0:
              x=0
          elif x&gt;pad_width-fight_width:
              x=pad_width-fight_width
  
          drawObject(fighter,x,y)
          enemy_y+=enemy_speed
          if enemy_y&gt;pad_height:
              enemy_y=0
              enemy_x=random.randrange(0,pad_width-enemy_width)
  
          drawObject(enemy,enemy_x,enemy_y)
  
          pygame.display.update()
          clock.tick(60)
  
          pygame.quit()
  
  def initGame():
      global gamepad,clock ,fighter,enemy
  
      pygame.init()
      gamepad=pygame.display.set_mode((pad_width,pad_height))
      fighter=pygame.image.load('fighter.png')
      enemy=pygame.image.load('enemy.png')
      clock=pygame.time.Clock()
  
  initGame()
  runGame()  #and here
  </code></pre>