pygame.error: video system not initialized

后端 未结 8 1236
情深已故
情深已故 2020-12-11 05:42

so I get this error when I try to run my pygame code: pygame.error: video system not initialized

i specify where the wing IDE tells me it is in the code below

8条回答
  •  忘掉有多难
    2020-12-11 06:11

    I had this issue recently, and I discovered a strange and unusual bug in the code that I'd written -- only after reading it and re-reading it a dozen times over a 10 minute stretch, trying to launch the file (which looked perfect) a dozen times.

    There was pygame.init(). There was screen = pygame.display.set_mode((size)) with the variable size in position to be available in the global namespace.

    Turns out it was the main game loop.

    # main game loop
    while RUNNING == True:
        for tneve in pygame.event.get():
            if tneve.type == QUIT:
                print(tneve)
                RUNNING = False
            loop()
            render()
            CLOCK.tick(FPS)
        cleanup()
    # End
    

    What a pain!

    P.S. The problem is the one-stop-too-far indentation of everything below RUNNING = False.

提交回复
热议问题