【发布时间】:2023-01-25 23:34:14
【问题描述】:
我正在做一个项目,当我将 clock.tick 添加到我的主游戏循环时,我的 pygame 窗口没有关闭。
def game_loop():
"""The main game loop that runs as the game runs. Returns when the pygame window is closed."""
global running
global timer
while running:
while timer > screen.fixed_fps:
fixed_update()
timer -= screen.fixed_fps
update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
return
screen.clock.tick(screen.fps)
timer += delta_time()
pygame.quit()
return
当我点击 X 时,屏幕会冻结,直到我松手,但除非我在非常特定的时间范围内点击 X(我通常需要点击它 20 次才能关闭)它不起作用。
【问题讨论】: