模块“pygame”没有“退出”成员,模块“pygame”没有“退出”成员

时间:2021-04-15 21:51:56

标签: python visual-studio-code pygame python-3.9

我正在使用 Pygame 创建游戏,我正在运行 Python 3.9.4,但是当我尝试时,我的 VsCode 似乎有问题设置程序如何关闭,你可以看到我的代码和图片中的问题,我也有同样令人失望的问题,乌龟模块,我认为这只是乌龟模块的一个失败,但它也发生在 Pygame。

有问题的代码 enter image description here

准备复制和粘贴的代码

import pygame


# Display settings
WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("G Space War")

WHITE = (255, 255, 255)


def draw_window():
    WIN.fill(WHITE)
    pygame.display.update()


def main():
    run = True
    while run:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:  # First Problem line
                run = False

        draw_window()
    pygame.quit()     # Second Problem line


if __name__ == "__main__":
    main()

0 个答案:

没有答案