I'm creating my first Python game ever, and I tried to do pause/unpause game function. I have created a global pause
variable which is set to false
by declaration. But when i press press button assigned to my pause function the programs gives me this error:
local variable 'pause' referenced before assignment
Here's paused()
function assignment to a button:
if event.key == pygame.K_p:
pause = True
paused()
And here's my paused()
function:
def paused():
while pause:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_m:
pause = False
pygame.display.update()
clock.tick(15)
#gameDisplay.fill(white) `