关于python:Pygame游戏循环语法错误

Pygame game loop syntax error

我只是在pygame中进行一些开发,却遇到了一些非常奇怪的麻烦。 这是我的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pygame, sys
from pygame.locals import *

#Declarin some variables
WINHEIGHT = 320
WINWIDTH = 640
red = (255, 0, 0)

pygame.init()
DISPLAY = pygame.display.set_mode((WINWIDTH, WINHEIGHT))
pygame.display.set_caption('My First PyGame')
FONT = pygame.font.Font(None, 32)

while True:

    pygame.draw.circle(DISPLAY, red, (100, 100)

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

我在第18行收到无效的语法错误,说

1
2
for event in pygame.event.get():
                               ^

即使不是语法错误,也可以帮助吗?


注意上面的行:

1
pygame.draw.circle(DISPLAY, red, (100, 100)

您缺少括号:

1
pygame.draw.circle(DISPLAY, red, (100, 100))


您错过了)
只是把那个
(pygame.draw.circle(DISPLAY, red, (100, 100) # here!