python 2.7 - UnboundLocalError: local variable 'lead_x' referenced before assignment -


def gameloop():     gameexit = false      lead_x_change = display_width/2     lead_y_change = display_width/2      lead_x_change = 0     lead_y_change = 0      while not gameexit:         event in pygame.event.get():             if event.type == pygame.quit:                 gameexit = true             if event.type == pygame.keydown:                 if event.key == pygame.k_left:                     lead_x_change = -block_size                     lead_y_change = 0                 elif event.key == pygame.k_right:                      lead_x_change = block_size                      lead_y_change = 0                 elif event.key == pygame.k_up:                     lead_y_change = -block_size                     lead_x_change = 0                 elif event.key == pygame.k_down:                     lead_y_change = block_size                     lead_x_change = 0          if lead_x >= display_width or lead_x < 0 or lead_y >= display_height or lead_y < 0 :            gameexit = true 

the unboundlocalerror reads:

local variable 'lead_x' referenced before assignment.

please knows how tackle this. in advance!


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -