import pygame
from pygame.locals import*
def main():
global FPSCLOCK, DISPLAYSURF, BASICFONT, PLAY_SURF, PLAY_RECT, NEW_SURF, NEW_RECT, SOLVE_SURF, SOLVE_RECT
bla
I assume you mean this error occurs when you quit the game. pygame.quit()
uninitializes all pygame modules, but the while loop still keeps running and when pygame.display.update()
is called, the video system is not initialized anymore and the error is caused. To fix that problem do something like this:
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = False
# Game code ...
# After the while loop is done, uninitialize pygame and exit the program.
pygame.quit()
sys.exit() # import sys at the top of the module.