[每当我尝试在我的pygame代码中包含“ screen.fill(在此处插入值)”时,窗口立即崩溃。我可以将其注释掉,而我的代码也可以正常工作。我真的不确定为什么。
[我已经尝试过使用其他人的代码来移动这条线,但是没有运气。
import pygame
pygame.init()
win = pygame.display.set_mode((1000, 800))
pygame.display.set_caption("Tetris")
img=pygame.image.load("C:\\Users\\Charlotte\\Desktop\\tetris_grid.png")
win.blit(img,(450, 150))
running = True
while running:
screen.fill(0, 0, 0)
pygame.display.update()
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
当我运行包含该行的代码时,窗口将打开,然后立即关闭。