2017-09-25 66 views
0

我編程pygame的項目,我會告訴你...pygame.init錯誤:視頻系統未初始化

import pygame 
pygame.init() 

WHITE = (255, 255, 255) 
pad_width = 1024 
pad_height = 512 

def runGame(): 
    global gamepad, clock 

crashed = False 
while not crashed: 
    for event in pygame.event.get(): 
     if event.type == pygame.QUIT: 
      crashed = True 

     gamepad.fill(WHITE) 
     pygame.display.update() 
     clock.tick(60) 

    pygame.quit() 


def initGame(): 
    global gamepad, clock 

    pygame.init() 
    gamepad = pygame.display.set_mode((pad_width, pad_height)) 
    pygame.display.set_caption('Pyflying') 

    clock = pygame.time.Clock() 
    runGame() 


initGame()   

這是代碼,現在的錯誤....

Traceback (most recent call last): 
File "C:/Users/dongjune/Desktop/PyCharm/scratch.py", line 36, in <module> 
    initGame() 
File "C:/Users/dongjune/Desktop/PyCharm/scratch.py", line 33, in initGame 
    runGame() 
File "C:/Users/dongjune/Desktop/PyCharm/scratch.py", line 14, in runGame 
    for event in pygame.event.get(): 
pygame.error: video system not initialized 

我不知道如何編程....如果你知道錯誤,請回答! 而且,我是pygame的新手......ㅠ。ㅠ如果你知道如何使用pygame,請告訴我!謝謝....

回答

1

你的縮進是錯誤的,解決這個問題:

​​
+0

哦,那麼你必須刪除'pygame.quit()'。它在錯誤的地方。 – JJAACCEeEKK

+0

好的答案!!!!!謝謝! – sjkim104

相關問題