2
即使我複製粘貼了命令語法並放置了我的變量,但我在pygame.draw.rect(screen, (0, 255, 0), (200, 150, 100, 50), 2)
上遇到錯誤。Pygame.draw.rect無效語法
#! /usr/bin/env python
import pygame, sys
from pygame.locals import *
clock = pygame.time.Clock()
LEFT=1
width= 1000
height=500
running =1
x = 0
y = 0
isdown = False
screen = pygame.display.set_mode((width, height))
while running:
for event in pygame.event.get():
#screen.fill((90,90,90))
if event.type == pygame.QUIT:
running=0
if event.type ==pygame.MOUSEBUTTONDOWN and event.button== LEFT:
isdown = True
t=event.pos
x,y=t
if event.type == pygame.MOUSEMOTION:
if isdown:
t=event.pos
x,y=t
if event.type ==pygame.MOUSEBUTTONUP and event.button== LEFT:
isdown=False
if isdown:
#rect= ((32*int(x/32),(32*int(y/32)),32,32)
pygame.draw.rect(screen,(0,255,0),(200,150,100,50),2)
clock.tick(3000)
pygame.display.flip()
錯誤:
File "PATH(not giving it)", line 30
pygame.draw.rect(screen,(0,255,0),(200,150,100,50),2)
^
SyntaxError: invalid syntax
不錯的偵探工作。我敢打賭,你是對的。 – Brionius