gpt4 book ai didi

python - Pygame 窗口在几秒钟后没有响应

转载 作者:太空狗 更新时间:2023-10-30 00:25:14 24 4
gpt4 key购买 nike

这段简单的代码在几秒后(大约 5 秒)崩溃(窗口没有响应)。

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480), 0, 24)
#clock = pygame.time.Clock()

#font = pygame.font.Font(None, 32)

cycles = 0
while True:
screen.fill(0)
# text = font.render('Cycles : %d' % cycles, True, (255, 255, 255))
# screen.blit(text, (100, 100))

cycles += 1

pygame.display.update()

如果我取消注释注释行,我可以清楚地看到程序在显示 47 到 50 之间的值时失控。

我使用 python 2.7 和 pygame 1.9.2、Windows 8(64 位)和 Eclipse + PyDev。

最佳答案

在 while 循环开始时调用 pygame.event.get()

关于python - Pygame 窗口在几秒钟后没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20165492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com