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
Post a Comment