为什么这段代码不起作用?它表示语法无效且指向pygame.display.update()
。我有python 3.5.2和pygame-1.9.2rc1-cp35-cp35m-win32.whl
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pygame, sys
from pygame.locals import *
pygame.init()
Ikkuna = pygame.display.set_mode((250, 200), 0, 32)
pygame.display.set_caption('Erilaisia kuvioita')
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
Ikkuna.fill(WHITE)
pygame.draw.circle(Ikkuna, BLACK, (75, 100), 50, 0)
pygame.draw.rect(Ikkuna, RED, (20, 155, 200, 25))
pygame.draw.polygon(Ikkuna, GREEN, ((220, 50),(220,125, (140,125)), 0)
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
答案 0 :(得分:1)
您尚未关闭括号。
pygame.draw.polygon(Ikkuna, GREEN, ((220, 50),(220,125, (140,125)), 0)
应该是
pygame.draw.polygon(Ikkuna, GREEN, ((220, 50),(220,125), (140,125)), 0)