This is the code that I am working with:
import pygame
global lead_x
global lead_y
global lead_x_change
global lead_y_change
lead_x = 300
lead_y = 300
lead_x_c
Python's handling of "global" variables is indeed a bit weird, especially if you're not accustomed to it.
The simple fix for your problem is to move your global
declarations inside each function that uses those variables. So:
def playerUpdateMovement():
global lead_x
global lead_y
global lead_x_change
global lead_y_change
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
lead_x_change = -1
This tells Python that your use of lead_x_change
within the playerUpdateMovement
function is actually a reference to a global variable, and not a use of a local variable (of the same name), which is the default treatment.