pygame.error: video system not initialized

后端 未结 8 1214
情深已故
情深已故 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:28

    You haven't called pygame.init() anywhere.

    See the basic Intro tutorial, or the specific Import and Initialize tutorial, which explains:

    Before you can do much with pygame, you will need to initialize it. The most common way to do this is just make one call.

    pygame.init()
    

    This will attempt to initialize all the pygame modules for you. Not all pygame modules need to be initialized, but this will automatically initialize the ones that do. You can also easily initialize each pygame module by hand. For example to only initialize the font module you would just call.

    In your particular case, it's probably pygame.display that's complaining that you called either its set_caption or its flip without calling its init first. But really, as the tutorial says, it's better to just init everything at the top than to try to figure out exactly what needs to be initialized when.

    0 讨论(0)
  • 2020-12-11 06:31
    1. If you doing pygame.init() then solve the problem video system initialized. but you get the next error like:

    (AttributeError: tuple object has no attribute 'fill') this.


    1. this problem is solving when you doing this
    screen = pygame.display.set_mode((600, 400))
    

    but not doing like

    screen = screen_width, screen_height = 600, 400
    

    1. Then the full problem is solved.
    0 讨论(0)
提交回复
热议问题