我是 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条经验 获得超5个赞
首先pygame.init是没有函数调用。这个声明根本没有任何作用。您必须添加括号来调用init():
pygame.init()
此外,您错过了pygame.display.flip()在主应用程序循环中更新显示():
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
提交
取消