pygame.error: video system not initialized

You should stop your main loop when you want to exit the game.

My suggestions, either of

  • call exit() after pygame.quit()
  • set finish = True and start = False (though due to some indentation issues with your pasted code it’s not possible to tell that this would actually work)

You should call pygame.quit() only when you want to terminate your Python session.

My suggestion: if you want to call game() more than once, e.g. in an interactive session, you should remove the call to pygame.quit() inside game(). This function uninitializes pygame and naturally all attempts to call its functionality will fail then.

Leave a Comment