Advertisement

python烟花效果代码

阅读量:

以下

-- coding: utf-8 --

import math, random,time

import threading

import tkinter as tk

import re

#import uuid

Fireworks=[]

maxFireworks=8

height,width=600,600

class firework(object):

def init(self,color,speed,width,height):

#uid=uuid.uuid1()

self.radius=random.randint(2,4) #粒子半径为2~4像素

self.color=color #粒子颜色

self.speed=speed #speed是1.5-3.5秒

self.status=0 #在烟花未爆炸的情况下,status=0;爆炸后,status>=1;当status>100时,烟花的生命期终止

self.nParticle=random.randint(20,30) #粒子数量

self.center=[random.randint(0,width-1),random.randint(0,height-1)] #烟花随机中心坐标

self.oneParticle=[] #原始粒子坐标(100%状态时)

s

全部评论 (0)

还没有任何评论哟~