title: Making pygame wait for user click/input before proceeding (python quiz game)
body: <p>So I am trying to make a game on pygame which would display a vocabulary as a question and three answer choices. And if the user presses the correct answer, their score will go up by one, and the game will move on to the next vocabulary question.</p>
  
  <p>I store my questions in an 2D array called questions[], in each element of the array it holds the questions and answers for each question as [question, correct answer choice, answer choice, answer choice]. So the correct answer is always at index position [i][1]. I do randomize the order in which the answer choices are shown later. </p>
  
  <p>Now my problem is that my game goes through the questions without waiting for user input. The point was that it would wait for the user to click. When the user clicks, then it checks where the user click. The position of the user's mouse will determine which "answer box" the user pressed. Let's pretend the user pressed the first box. The game then compares whether the text stored in that box is correct (i.e the text is the same as questions[i][1]). It displays each question for a split second, and then moves on to the next question and the next question. </p>
  
  <p>But it does not wait for the user to click first. Not even, it doesn't even display the questions long enough for the user to read the question. Is there a way I can perhaps structure the loop or add certain conditions so that the program would display each question until the user chooses an answer, and then add the score and move on to the next question?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import pygame
  from random import randint
  from pygame import *
  
  pygame.init()
  pygame.font.match_font('Courier New.ttf')
  
  
  BLACK = (0, 0, 0)
  WHITE = (255, 255, 255)
  GREEN = (0, 255, 0)
  RED = (255, 0, 0)
  GREEN = (71, 212, 15)
  BLUE = (42, 250, 246)
  PINK = (255,102, 196)
  YELLOW = (255, 255, 0)
  i = 0
  
  size = (700, 500)
  screen = pygame.display.set_mode(size)
  
  pygame.display.set_caption("Spanish Space Quiz") 
  
  done = False
  
  questions = [["Hola", "Hello", "Goodbye", "Cow"],["Amigo", "Friend", "Cat", "Dog"],["Si", "Yes", "No", "Maybe"]]
  answerboxes = [[30,300,190,150,BLUE,WHITE,7],[255,300,190,150,YELLOW,WHITE,7],[480,300,190,150,PINK,WHITE,7]]
  score = 0
  choices = []
  
  def textObject (text, font):
      textWord = font.render(text, True, WHITE)
      return textWord, textWord.get_rect()
  
  def answerbutton(drawbox):
      mouse = pygame.mouse.get_pos()
  
      if drawbox[0]+drawbox[2] &gt; mouse[0] &gt; drawbox[0] and drawbox[1]+drawbox[3] &gt; mouse[1] &gt; drawbox[1]:
          pygame.draw.rect(screen, drawbox[5],(drawbox[0],drawbox[1],drawbox[2],drawbox[3]),drawbox[6])           
      else:
          pygame.draw.rect(screen, drawbox[4],(drawbox[0],drawbox[1],drawbox[2],drawbox[3]),drawbox[6])
  
      answerTextFont = pygame.font.SysFont("Courier New",60)
      textWord, textBox = textObject(drawbox[7], answerTextFont) #the text &amp; the "Text box"
      textBox.center = ( (drawbox[0]+(drawbox[2]/2)), (drawbox[1]+(drawbox[3]/2)) )
      screen.blit(textWord, textBox)
  
  def questionbutton(message,x,y,w,h,color):
      mouse = pygame.mouse.get_pos()
      pygame.draw.rect(screen,color,(x,y,w,h))
  
      answerTextFont = pygame.font.SysFont("Courier New",60)
      textWord, textBox = textObject(message, answerTextFont) #the text &amp; the "Text box"
      textBox.center = ( (x+(w/2)), (y+(h/2)) )
      screen.blit(textWord, textBox)
  
  while not done:
      screen.blit (backgroundImage, [0,0])
      font = pygame.font.SysFont('Courier', 30, True, False)
      text = font.render("SPACE VOCBULARY QUIZ",True,WHITE)
      screen.blit(text, [30, 30])
      font = pygame.font.SysFont('Courier', 30, False, False)
      text = font.render("SCORE: ", True, WHITE)
      screen.blit(text, [500, 30])
  
      for event in pygame.event.get():
          if i == (len(questions)): #if user clicks close then done becomes true and game quits
              done = True
              event.type == pygame.QUIT
          for c in range (len(questions)):
              mouse = pygame.mouse.get_pos()
              click = pygame.mouse.get_pressed()
              questionbutton((questions[c][0]),30,150,640,100,GREEN)
              for n in range(3):
                  choices.append(questions[c][n+1])
              for r in range(3):
                  randomPointer = randint(0, (len(choices)-1))
                  answerboxes[r].append(choices[randomPointer])
                  choices.remove(choices[randomPointer])
                  answerbutton(answerboxes[r][0:8])
              if click[0] == 1: 
                  for a in range(3):
                      if answerboxes[a][0]+answerboxes[a][2] &gt; mouse[0] &gt; answerboxes[a][0] and answerboxes[a][1]+answerboxes[a][3] &gt; mouse[1] &gt; answerboxes[a][1]:
                          if answerboxes[a][7] == questions[i][1]:
                              score = score + 1
                              print (score)
              for g in range (3):
                  answerboxes[g].pop()           
              i = i+1
  
      pygame.display.update()
  
  pygame.quit()
  </code></pre>