2016-03-07 41 views
0

我正在製作一款使用Python 3.5.1/Pygame的遊戲,而且我需要製作一個從天花板落下的滴。這是我的原代碼:根據倒計時對圖像進行潤色

def dropping(X,startY,endY,speed): 
    if drip == True: 
     for index in range(startY,endY,speed): 
      screen.blit(drop,(X,index)) 

while insert_variable_here == True: 
    dropping(X,startY,endY,speed) 
    pygame.display.update() 

此代碼的blit這一切在一次,而不是等待「insert_variable_here」的下一個循環。我怎樣才能解決這個問題?

+2

對於初學者來說,不要在一個循環中定義的功能。 – Gerrat

+0

@Gerrat啊謝謝你。這並不意味着要這樣打字。我現在編輯它。 –

回答

0

那麼你可以嘗試將倒數作爲一個字符串存儲,然後使用if語句來確定哪個圖像blit。

(我沒有使用pygame的是月,已經忘記了如何做塊,但你的想法)

import time 
import pygame 
*code here* 
countdown = str(your countdown code) 
if countdown > 60: 
    blit the image