我是 pygame 的新手,我只是想用它編寫國際象棋代碼,但是我在后臺加載時遇到了麻煩我查閱了很多教程,我認為一切都很好,我在做什么花了這么多時間?import pygame pygame.init#create the screen with 800 pixals width and 600 pixals hieghtscreen = pygame.display.set_mode((800,600))# Backgroundbackground = pygame.image.load("chessboard.png")running = Truewhile running: #RGB colors screen.fill((234,0,0)) #background image screen.blit(background,(0,0)) for event in pygame.event.get(): if event.type == pygame.QUIT: running = Falsepygame.quit()
1 回答

RISEBY
TA貢獻1856條經(jīng)驗 獲得超5個贊
首先pygame.init是沒有函數(shù)調(diào)用。這個聲明根本沒有任何作用。您必須添加括號來調(diào)用init():
pygame.init()
此外,您錯過了pygame.display.flip()在主應用程序循環(huán)中更新顯示():
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
#RGB colors
screen.fill((234,0,0))
#background image
screen.blit(background,(0,0))
# update display
pygame.display.flip()
添加回答
舉報
0/150
提交
取消