2015-02-23 23 views
0

在我pygame的文件我有:pygame的錯誤:沒有視頻模式已設置W/livewires

from livewires import games 
import math, random 

class Ship(games.Sprite): 
    image = games.load_image("images\ship.bmp", transparent = True) 

,並給出了錯誤:

pygame error: No video mode has been set 

我使用livewires導入pygame的使用,而這post沒有給我的電腦正確的答案。

回答

0

需要初始化你livewires顯示,像這樣:

from livewires import games 
import math, random 

games.init(screen_width = 640, screen_height = 480, fps = 60) 

# game logic here 

games.screen.mainloop() # mainloop of the display 
+0

程序不顯示錯誤,但窗口反而閃爍並在半秒後消失 – jreiss1923 2015-02-23 20:44:18

+0

您是否稱過顯示器的主循環? – 2015-02-23 20:46:01

+0

我現在感覺像一個阻礙!感謝您的幫助:) – jreiss1923 2015-02-23 20:51:13

0

就像那個帖子裏說,你需要設置

screen = pygame.display.set_mode((800, 600)) # change to the real resolution 

某處你的船類以外(如您的主要方法)。您的船艙用於在遊戲中生成物體,而不是創建遊戲窗口。

如果要保持所有的類都在一個文件中,你可以試試:

from pygame.locals import * 
from livewires import games 
import math, random 

def main(): 
    pygame.init() 
    screen = pygame.display.set_mode((800, 600)) # change to the real resolution 


class Ship(games.Sprite): 
    image = games.load_image("images\ship.bmp", transparent = True) 

if __name__ == '__main__': 
    main()