Python烟花代码简单易复制,教你如何编写Python烟花代码

大家好,本文将围绕Python烟花代码总体功能介绍展开说明,python烟花代码简单可复制是一个很多人都想弄明白的事情,想搞清楚python烟花代码怎么写需要先了解以下几个事情。

Source code download: 本文相关源码

疫情太严重了,有很多小伙伴都不能出门玩耍了。给大家看一个特别的风景吧,Python烟花代码,虽然没有现实中的烟花那么美丽,但是在特殊时期足矣安慰自己了Python中Turtle画蝴蝶。(https://jq.qq.com/?_wv=1027&k=hDGOjqqw)

先给大家看一下效果图

代码如下

# -*- 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%状态时)
        self.rotTheta=random.uniform(0,2*math.pi)  #椭圆平面旋转角

        #椭圆参数方程:x=a*cos(theta),y=b*sin(theta)
        #ellipsePara=[a,b]

        self.ellipsePara=[random.randint(30,40),random.randint(20,30)]   
        theta=2*math
物联沃分享整理
物联沃-IOTWORD物联网 » Python烟花代码简单易复制,教你如何编写Python烟花代码

发表评论