2016-03-07 46 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