简体   繁体   中英

Pygame game loop syntax error

I'm just doing some development in pygame and I've run into some very strange trouble. This is my code:

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()

I get an invalid syntax error on line 18 saying that

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

Is a syntax error even though it isn't, help?

Note the line above:

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

You are missing a parenthesis:

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

You missed a ) in
Just put that (pygame.draw.circle(DISPLAY, red, (100, 100) # here!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM