import pygame
pygame.init()
x = height,width = (800,600)
Display = pygame.display.set_mode(x)
pygame.display.set_caption("Blocky")
red = (157, 139, 215)
black = (0,0,0)
Display.fill(red)
pygame.draw.rect(Display,black,(120,450,600,50))
#It updates every frame
pygame.display.update()
excape = False
while not excape:
for dork in pygame.event.get():
print(dork)
if pygame.event == pygame.QUIT:
pygame.quit()
quit()
这里的打印(呆子)是工作,但当我点击退出按钮的窗口,它没有退出在所有。。 那么如何在1 while循环中打印事件并退出应用程序呢?你知道吗
您需要循环检查每个pygame事件,并检查该事件是否为退出。你知道吗
首先,应该在while not excape循环中更新屏幕。 其次,将excape设置为
True
ifpygame.event事件等于pygame.QUIT
。 因此,您的代码如下所示:相关问题 更多 >
编程相关推荐