title: pygame help in "game function" for loop value is not increasing nor decreasing
body: <p>I am using a pygame to develop a game that will show two buttons along with an image. The user will have to choose the right button that describes the image. The difficulty I am having that I am not able to increment I variable for the (for loop line 101). I have  noticed the while loop is running infinitely even though I tried brake out of it. When I click on the button, I am not getting the response (correct or wrong as programed in st2 s2t functions)</p>
  <p>To summarize I'm trying to capture users responses from the game function and determine whether the user made the right decision or not from st2 or s2t. And go back to the game function and increment I and execute the next elif statement and again call the st2 or s2t and so on.</p>
  <pre><code># -*- coding: utf-8 -*-
  &quot;&quot;&quot;
  Created on Mon Sep  7 17:15:42 2020
  
  @author: okand
  &quot;&quot;&quot;
  # -*- coding: utf-8 -*-
  &quot;&quot;&quot;
  Created on Mon Sep  7 17:15:42 2020
  
  @author: okand
  &quot;&quot;&quot;
  import glob
  import pygame
  import random #we use this to make a random right button
  import time 
  import os 
  pygame.init() # intialize all pygame 
  
  &quot;setting up the display parameters&quot;
  display_width = 600
  display_height = 600
  
  &quot;setting up the colors and the bright's&quot;
  black = (0,0,0)
  alpha = (0,88,255)
  white = (255,255,255)
  red = (200,0,0)
  green = (0,200,0)
  blue = (0, 0, 255)
  bright_red = (255,0,0)
  bright_green = (0,255,0)
  
  
  &quot;&quot;&quot;&quot;Setting display. note the standard we use is 600*600 display limtation&quot;&quot;&quot;
  gameDisplay = pygame.display.set_mode((display_width,display_height))
  pygame.display.set_caption('GUI Speech Recognition') #title of the window
  gameDisplay.fill(white)
  
  
  &quot;&quot;&quot; Loading images to the paython from the pic file &quot;&quot;&quot;
  current_path = os.path.dirname(__file__)
  
  image_path = os.path.join('image')
  def load_the_image(image):
      images = [
          load_the_image('lalaa.jpg'),
          load_the_image('Ross.jpg'),
          load_the_image('gator.jpg'),
          load_the_image('blue_sea_water.jpg'),
          load_the_image('mountains.jpg'),
          load_the_image('elif.jpg')
     ]
  
  
  def close():
      pygame.quit()
      quit()
  
  def message_display(text):
      largeText = pygame.font.Font('freesansbold.ttf',30)
      TextSurf, TextRect = text_objects(text, largeText)
      TextRect.center = ((display_width/2),(display_height/2))
      gameDisplay.blit(TextSurf, TextRect)
      pygame.display.update()
      
  
      
  def text_objects(text, font):
      textSurface = font.render(text, True, alpha)
      return textSurface, textSurface.get_rect()
  
  
  
  
  &quot;&quot;&quot; This function is to set the button parameters x_axis Y_axis width height 
  Also, when you hit the button it will take an action &quot;&quot;&quot;
  def button(msg,x,y,w,h,ic,ac,action=None):
      mouse = pygame.mouse.get_pos()
      click = pygame.mouse.get_pressed()
      if x+w &gt; mouse[0] &gt; x and y+h &gt; mouse[1] &gt; y:
          pygame.draw.rect(gameDisplay, ac,(x,y,w,h))
  
          if click[0] == 1 and action != None:
              action()         
      else:
          pygame.draw.rect(gameDisplay, ic,(x,y,w,h))
  
      smallText = pygame.font.SysFont(&quot;comicsansms&quot;,20)
      textSurf, textRect = text_objects(msg, smallText)
      textRect.center = ( (x+(w/2)), (y+(h/2)) )
      gameDisplay.blit(textSurf, textRect)
  
  
  
  def s2t():
      carImg= game()
      gameDisplay.blit(carImg,(0,0))    
      message_display('good job')
      print('good job')
    
  def st2():
      carImg= game()
      gameDisplay.blit(carImg,(0,0))  
      message_display('wrong')
      print('wrong')
      
  
  
  
  &quot;&quot;&quot;This function is for checking the value i  of the , changes the loaded pictures as well 
  as the button options. to get the response s2t &amp; st2 functions are called&quot;&quot;&quot;    
  
  def game ():
     aseel = 1
     while aseel == 1: 
         
         for event in pygame.event.get():
          for i in range(1,3):
              
  
              if i == 1:
                   carImg = pygame.image.load(os.path.join(image_path, 'lalaa.jpg'))
                   gameDisplay.blit(carImg,(0,0))
                   pygame.display.update()
              
                   NewRightButton = 1   #random.randint(1,2)
                   
                   if NewRightButton == 1:
                      button(&quot;Dog&quot;,150,450,100,50,green,bright_green,s2t)
                      button(&quot;Cat&quot;,50,450,100,50,blue,bright_green,st2)
                      #code that says which the right button is
                      pygame.display.update() 
                      # time.sleep(3)        
                      break  
                   else:
                      button(&quot;Cat&quot;,150,450,100,50,green,bright_green,st2)
                      button(&quot;Dog&quot;,50,450,100,50,blue,bright_green,s2t)
                      #code that says which the right button is
                      #This makes the buttons swap back and forth
                      pygame.display.update() 
                      # time.sleep(3)
                      break 
                   aseel = aseel + 1
                   print (aseel)
              elif i == 2: 
                   carImg = pygame.image.load(os.path.join(image_path, 'Ross.jpg'))
                   gameDisplay.blit(carImg,(0,0))
                   pygame.display.update()
              
                   NewRightButton = 1   #random.randint(1,2)
                   
                   if NewRightButton == 1:
                      button(&quot;ross&quot;,150,450,100,50,green,bright_green,s2t)
                      button(&quot;Cat&quot;,50,450,100,50,blue,bright_green,st2)
                      #code that says which the right button is
                      pygame.display.update() 
                      # time.sleep(3)        
                      break  
                   else:
                      button(&quot;Cat&quot;,150,450,100,50,green,bright_green,st2)
                      button(&quot;ross&quot;,50,450,100,50,blue,bright_green,s2t)
                      #code that says which the right button is
                      #This makes the buttons swap back and forth
                      pygame.display.update() 
                      # time.sleep(3)
                      break 
              elif i == 3: 
                   carImg = pygame.image.load(os.path.join(image_path, 'gator.jpg'))
                   gameDisplay.blit(carImg,(0,0))
                   pygame.display.update()
              
                   NewRightButton = 1   #random.randint(1,2)
                   
                   if NewRightButton == 1:
                      button(&quot;gator&quot;,150,450,100,50,green,bright_green,s2t)
                      button(&quot;Cat&quot;,50,450,100,50,blue,bright_green,st2)
                      #code that says which the right button is
                      pygame.display.update() 
                      # time.sleep(3)        
                      break  
                   else:
                      button(&quot;Cat&quot;,150,450,100,50,green,bright_green,st2)
                      button(&quot;gator&quot;,50,450,100,50,blue,bright_green,s2t)
                      #code that says which the right button is
                      #This makes the buttons swap back and forth
                      pygame.display.update() 
                      # time.sleep(3)
                      break 
                   aseel = aseel + 1 
                   print (aseel)
                  
              else :
                  aseel = aseel + 1
                  continue 
              print ('end of the game')
              aseel = aseel + 1
               
          
       
   
                  
          
              
  def trake_mouse():   #To  track mouse position
      gameExit = False
      while not gameExit:
          for event in pygame.event.get():
              print (event)
  
  &quot;&quot;&quot;&quot; In The main function is to show the first screen with 
  two buttons options play or quit. if the user choses quit. the game will quit.
  On the other hand, if the user choses to play button. it is going to take him 
  to game function  &quot;&quot;&quot;
  def main ():
       while True:
          for event in pygame.event.get():
                   if event.type == pygame.QUIT:
                          pygame.quit()
                          quit()
          pygame.display.update()
          button(&quot;Quit&quot;,450,250,100,50,red,bright_red,close)
          button(&quot;play&quot;,150,250,100,50,green,bright_green,game)
          pygame.display.update()   
       
          
  if __name__ == '__main__':
      main()
  
  
  </code></pre>