我有一個問題,我希望今天有人能幫助我,如果你能的話,請按照我被困住的方式去做,這里的文章告訴我,我被告知的錯誤應該有效。我正在使用 IntelliJ 的 PyCharm 和最新版本的 python - 3.8.5 所以我的目標是讓我的 PyGame 窗口變成白色,因為在啟動時它是黑色的,所以當我輸入以下代碼時會出現這個錯誤:import pygame# Initialise the pygame functions#pygame.init()# Create the screen for the user#root = pygame.display.set_mode((800, 600))pygame.display.set_caption("Space Invaders")icon = pygame.image.load("space.png")pygame.display.set_icon(icon)# Makes the pygame window appear for longer than a few milliseconds#runtime = Truewhile runtime: for event in pygame.event.get(): if event.type == pygame.QUIT: runtime = False screen.fill(255, 255, 255) #The error appears here and I cant find out why because I have looked at articles and they say this should work# pygame.display.update()PyCharm 的響應是:pygame 1.9.6Hello from the pygame community. https://www.pygame.org/contribute.htmlTraceback (most recent call last): File "C:/Users/doesnotcompute10/OneDrive/Main Doccuments/Personal/Code/Code.PythonPycharm/PyGame/Learning/Space Invaders.py", line 25, in <module> screen.fill(255, 255, 255)NameError: name 'screen' is not definedProcess finished with exit code 1如果有人知道如何解決,請回復和/或發送電子郵件至 [email protected]
添加回答
舉報
0/150
提交
取消