我執行下面的代碼,只是得到一個空白(黑色)窗口。Python pygame新手代碼顯示空白屏幕
窗口標題顯示,但我還沒有得到圖像加載(我試圖使用其他圖像比使用的圖片)。 .py文件和圖像位於相同的目錄中。
background_image_filename='checkmark.jpg'
mouse_image_filename='digestive_bw.png'
import pygame, sys
from pygame.locals import*
from sys import exit
pygame.init()
screen=pygame.display.set_mode((800,800),0,32)
#pygame.display.set_caption("Hello, Howdy, Mate, and Hi there world!")
background=pygame.image.load(background_image_filename).convert()
mouse_cursor=pygame.image.load(mouse_image_filename).convert_alpha()
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
screen.blit(background,(0,0))
x,y=pygame.mouse.get_pos()
x-=mouse_cursor.get_width() /2
y=-mouse_cursor.get_height() /2
screen.blit(mouse_cursor,(x,y))
pygame.display.update()
我已經用pygame 1.9.2安裝了python 3.2。如果我無法得到這個工作,我會考慮卸載並安裝3.1 + 1.9.1。