0
playerOnePosition = (WINDOWHEIGHT - PADDLESIZE) /2
y = 0
moveY = 0
#Creates Rectangles for ball and paddles.
paddle1 = pygame.Rect(PADDLEOFFSET,(playerOnePosition,(y)), LINETHICKNESS,PADDLESIZE)
drawPaddle(paddle2)
clock = pygame.time.Clock()
while True: #main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# mouse movement commands
if (event.type == pygame.KEYDOWN):
if(event.key == pygame.K_DOWN):
moveY = -5
if (event.key == pygame.K_UP):
moveY = 5
if (event.type == pygame.UP):
if(event.key == pygame.K_DOWN):
moveY = 0
if (event.key == pygame.K_UP):
moveY = 0
y += moveY
clock.tick(50)
我的代碼的這部分工作不正常,我試圖設置鍵使槳上下移動,但我無法弄清楚我的代碼出了什麼問題。參數必須是矩形對象
的錯誤是:Argument must be rect style object
您能否提供[MCVE](http://stackoverflow.com/help/mcve)? – Adalee
@Adalee我是新來的,我已經做對了嗎? –
@Joaqin如果我複製你的代碼,由於變量的導入和聲明,它無法運行。因爲我們無法確定你的變量包含什麼(例如'LINETHICKNESS'),所以我們不能告訴你究竟是什麼錯誤。 – Adalee