Python 3.3.2语法错误无效

时间:2013-07-12 13:36:47

标签: python

bif="Sadness.jpg"

mif="circles.png"

import pygame,sys

from pygame.locals import *

pygame.init()

screen=pygame.display.set_mode((640,360),0,32)

background=pygame.image.load(bif).convert()

mouse_c=pygame.image.load(mif).convert_alpha()

x,y=0,0

movex, movey = 0,0

while True:

    for event in pygame.event.get():

        if event.type == QUIT:

            pygame.quit()

            sys.exit()


            if  event.type == KEYDOWN:
                if event.key==K_LEFT:
                    movex=-1
                elif event.key==K_RIGHT:
                    movex=+1
                elif event.key==K_UP:
                    movey=-1
                elif event.key==K_DOWN:
                    movey=+1
            if event.type == K_UP:
                  if event.key==K_LEFT:
                    movex=0
                  elif event.key==K_RIGHT:
                    movex=0
                  elif event.key==K_UP:
                    movey=0
                  elif event.key==K_DOWN:
                    movey=0

            x+=movex
            y+=movey

            screen.blit(background, (0,0))
            screen.blit((mouse_c,(x,y))


            pygame.display.update()

2 个答案:

答案 0 :(得分:2)

screen.blit((mouse_c,(x,y))

您似乎有一个额外的括号(。这将使python认为你继续下一行的代码,但你不是故意这样做的,因此你创建了一些奇怪的语法(因此是SyntaxError)。这也是为什么你的回溯实际上可能不会指向带有额外括号的行,而是指向它下面的那一行。

答案 1 :(得分:1)

screen.blit((mouse_c,(x,y))

有一个开括号太多(或缺少右括号)。

相关问题