PHeMoX not sure if this will help
A particle fireworks that leaves a trail
SetWindowTitle( "fireworks" )
SetWindowSize( 640, 480, 0 )
// set display properties
SetVirtualResolution( 640, 480 )
SetOrientationAllowed( 0, 0, 1, 1 )
SetVSync(1)
#constant maxNumberFireworks=5
#constant speed=1.0
#constant frequency=3.14
type fireworkType
flag as integer //1 do firework 0 dont do
startTime as integer
endtype
dim fire [maxNumberFireworks] as fireworkType //variable to hold the present particle emmitter
for num = 1 to maxNumberFireworks
setupFirework(num)
fire[num].flag=0
next num
dim blackFire [maxNumberFireworks] as fireworkType
for num = 1 to (maxNumberFireworks)
blackFire[num].flag=0
setupFirework(num+100)
AddParticlesColorKeyFrame(num+100,1,0,0,0,255)
next num
bg = createsprite(0)
setspritesize(bg,GetVirtualWidth(), GetVirtualHeight())
SetSpriteColor(bg,0,0,0,8)
start_time = GetMilliseconds()
CreateRenderImage (1,640,480,0,0)
ClearScreen()
do
SetRenderToImage (1,0)
DrawSprite(bg)
for num=1 to maxNumberFireworks
if (fire[num].flag=0) and random(1,100)<10 //a 5 percent chance of that particle being emitted
doFirework(num)
fire[num].flag=1
blackFire[num].flag=0
fire[num].startTime= GetMilliseconds()
UpdateParticles(num,0)
endif
current_time = GetMilliseconds()
if fire[num].flag=1 and(current_time-fire[num].startTime)>50
blackFire[num].flag=1
// doBlackFirework(num+100,num)
// UpdateParticles(num+100,0)
endif
if GetParticlesMaxReached(num)=1 //and GetParticlesMaxReached(num+100)=1
fire[num].flag=0
blackFire[num].flag=0
//ClearScreen()
endif
next num
//ClearScreen()
Update(0)
Render()
setrendertoscreen ()
createsprite(2,1)
Update(0)
Render()
swap()
loop
function setupFirework(obj as integer)
CreateParticles(obj,100,100) //id,x,y
SetParticlesSize(obj,2) //pixel size of particles
SetParticlesLife(obj,5) //sets the length of 5 seconds the particles live
SetParticlesMax(obj,75) //max number of particles set to 75 f
`SetParticlesActive(1,0)
AddParticlesForce(obj,1,4,0,15) //The time a particle has to wait before forces apply
SetParticlesFrequency(obj,100) //Sets the frequency of new particle generation
SetParticlesVelocityRange(obj,2,4) //velocity factor of particles ranging from min of 2 to 4
SetParticlesColorInterpolation(obj,0) //1 smooth 0 none
SetParticlesVisible( obj, 0 ) //hide particles when they first created so as timer can be used
//SetParticlesFaceDirection( obj,1 )
endfunction
function doFirework (obj as integer)
SetParticlesVisible( obj, 1 ) //make particle visible
SetParticlesPosition(obj,Random(100,GetVirtualWidth()-100),Random(100,GetVirtualHeight()-100))
ResetParticleCount(obj)
AddParticlesColorKeyFrame(obj,1,Random(100,250),Random(100,250),Random(100,250),255)
AddParticlesColorKeyFrame(obj,2,Random(100,200),Random(100,200),Random(100,200),200)
AddParticlesColorKeyFrame(obj,4,Random(50,100),Random(50,100),Random(50,100),25)
endfunction
function doBlackFirework (obj as integer,obj2 as integer)
SetParticlesVisible( obj, 1 ) //make particle visible
SetParticlesPosition(obj,GetParticlesX(obj2),GetParticlesY(obj2))
ResetParticleCount(obj)
endfunction
fubar