python - Pygame 游戏循环语法错误

标签 python syntax pygame

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

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 行收到无效语法错误,说明了这一点

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

是否存在语法错误,即使不是,请帮忙?

最佳答案

注意上面的行:

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

你缺少一个括号:

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

关于python - Pygame 游戏循环语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14167490/

相关文章:

python - 在 google app engine python 中设置 cron 作业

python - NetworkX 中的非标准化中心性分数

syntax - 为什么以 "-->"开头的行不会在 Javascript 中引发错误?

c++ - 关于我在 C++ 代码中从未见过的特殊运算符的一些问题

python - 使用 Python 裁剪 AVI 文件

python - KivyMD ScrollView 示例

python - 转换时区 Pandas 数据框

c - 在C中,node.next->prev与node->next->prev相同吗?

python - 我正在尝试设置一个 if 语句来删除 Sprite ,而图像消失 Sprite 仍然存在(不断激活 if 语句

python - 显示 pygame 单元测试