"""
单击抛物粒子效果
"""
from sprites import * # 从精灵模块导入所有命令
def make_colors():
"""生成一个颜色"""
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
return r,g,b
screen = Screen()
screen.colormode(255)
squares = [Sprite(shape='circle',visible=False) for x in range(15)]
for sq in squares:
sq.da = -1 # 加速度
sq.scale(0.2) # 缩小
sq.color(make_colors()) # 设定颜色
def start_fall(x,y):
"""开始下落"""
screen.onclick(None) # 取消单击绑定
[sq.goto(x,y) for sq in squares]
for sq in squares:
sq.dx = random.randint(-5,5)
sq.dy = random.randint(5,10)
sq.show()
counter = 0
clock = Clock()
以下代码省略......
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

