#Constant FLYING 1
#Constant EXPLODING 2
#Constant UNACTIVE 3
Type FireWork
State as Byte
TrailParticlesNum as Integer
ExplodeParticlesNum as Integer
ExplodeTime as Integer
ExplodeTimeEnd as Integer
Speed as Float
aZ as Integer
X as Float
Y as Float
Endtype
Type Star
X as Integer
Y as Integer
BrightnessVal as Integer
Endtype
Load Image "C:UsersWillPicturesParticle.bmp",1
Dim FireWorks(0) as FireWork
Set Display Mode 1600,1200,32
Sync On
Autocam Off
Sync Rate 60
Color Backdrop 0
Position Camera 0,0,-300
Do
If Spacekey() = 1 and s = 0
MakeFirework()
s = 1
Endif
If Controlkey() = 1
MakeFirework()
Endif
If Spacekey() = 0 then s = 0
HandleFireworks()
Control Camera Using Arrowkeys 0,5,1
Sync
Loop
Function FreeParticles()
Repeat
Inc i
Until Particles Exist(i) = 0
Endfunction i
Function MakeFirework()
Array Insert At Top FireWorks(0)
FireWorks(1).TrailParticlesNum = FreeParticles()
Make Particles FireWorks(1).TrailParticlesNum,1,20,10
Set Particle Life FireWorks(1).TrailParticlesNum,5
Color Particles FireWorks(1).TrailParticlesNum,Rnd(255),Rnd(255),Rnd(255)
FireWorks(1).ExplodeParticlesNum = FreeParticles()
Make Particles FireWorks(1).ExplodeParticlesNum,1,20,10
Set Particle Emissions FireWorks(1).ExplodeParticlesNum,0
Set Particle Life FireWorks(1).ExplodeParticlesNum,10
Set Particle Gravity FireWorks(1).ExplodeParticlesNum,2
Color Particles FireWorks(1).ExplodeParticlesNum,Rnd(255),Rnd(255),Rnd(255)
FireWorks(1).ExplodeTime = Timer()+1000+Rnd(1000)
FireWorks(1).ExplodeTimeEnd = FireWorks(1).ExplodeTime+200+rnd(500)
FireWorks(1).aZ = 30 - Rnd(60)
FireWorks(1).State = FLYING
FireWorks(1).Speed = 0.5+(Rnd(10)/10.0)
Endfunction
Function HandleFireworks()
Count = Array Count(FireWorks(0))
For i = 1 to Count
If FireWorks(i).State = FLYING
FireWorks(i).X = FireWorks(i).X + Sin(FireWorks(i).aZ)*FireWorks(i).Speed
FireWorks(i).Y = FireWorks(i).Y + Cos(FireWorks(i).aZ)*FireWorks(i).Speed
Position Particle Emissions FireWorks(i).TrailParticlesNum,FireWorks(i).X,FireWorks(i).Y,0
Endif
If Timer() > FireWorks(i).ExplodeTime and FireWorks(i).State = FLYING
FireWorks(i).State = EXPLODING
Position Particle Emissions FireWorks(i).ExplodeParticlesNum,FireWorks(i).X,FireWorks(i).Y,0
`Rotate Particles FireWorks(i).ExplodeParticlesNum,90,0,0
Set Particle Emissions FireWorks(i).ExplodeParticlesNum,20
Set Particle Emissions FireWorks(i).TrailParticlesNum,0
Endif
If FireWorks(i).State = EXPLODING
If Timer() > FireWorks(i).ExplodeTimeEnd
Set Particle Emissions FireWorks(i).ExplodeParticlesNum,0
Endif
If Timer() > FireWorks(i).ExplodeTimeEnd+10000
Delete Particles FireWorks(i).ExplodeParticlesNum
Delete Particles FireWorks(i).TrailParticlesNum
FireWorks(i).State = UNACTIVE
`Array Delete Element FireWorks(0),i
`Dec i
Endif
Endif
Next i
Endfunction
Attached is the image. I knocked this together quickly but i think it makes a nice effect. Happy Fireworks day!