我一直在尝试让我的代码收集按下哪个鼠标按钮及其位置,但是每当我运行以下代码时,pygame 窗口都会冻结,并且外壳/代码会继续输出鼠标的起始位置。有谁知道为什么会发生这种情况,更重要的是如何解决它? (对于下面的代码,我使用了这个网站https://www.pygame.org/docs/ref/mouse.html和其他堆栈溢出答案,但它们对我的问题还不够具体。)
clock = pygame.time.Clock()
# Set the height and width of the screen
screen = pygame.display.set_mode([700,400])
pygame.display.set_caption("Operation Crustacean")
while True:
clock.tick(1)
screen.fill(background_colour)
click=pygame.mouse.get_pressed()
mousex,mousey=pygame.mouse.get_pos()
print(click)
print(mousex,mousey)
pygame.display.flip()