brunuu you could make use of the render commands and use particles
an example of fireworks below
#constant maxNumberFireworks=8
#constant speed=1.0
#constant frequency=3.14
#constant maxWidth=800
#constant maxHeight=600
SetWindowTitle( "fireworks" )
SetWindowSize( maxWidth, MaxHeight, 0 )
// set display properties
SetVirtualResolution( maxWidth, MaxHeight )
SetOrientationAllowed( 0, 0, 1, 1 )
SetDisplayAspect( -1 )
UseNewDefaultFonts( 1 ) // since version 2.0.20 we can use nicer default fonts
//SetVSync(1)
SetPrintSize(50)
do
if GetPointerPressed()
//congratulations("Congratulations tap screen to exit")
congratulations("Happy New Year")
endif
Print("tap screen for fireworks")
Sync()
loop
end
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
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 congratulations (text as String)
dim fireFlag [maxNumberFireworks] as integer //variable to hold the present particle emmitter
dim fireSound [maxNumberFireworks] as integer
SetSoundSystemVolume(100)
for num = 1 to maxNumberFireworks
setupFirework(num)
fireSound[num]=LoadSound("firework.wav")
SetSoundInstanceVolume(fireSound[num],75)
fireFlag[num]=0
next num
fireBg = createsprite(0)
setspritesize(fireBg,maxWidth,maxHeight)
SetSpriteColor(fireBg,0,0,0,8)
Print(text)
render() //draw all 2d and 3d to screen
myFireworkBackImage=GetImage(0,0,maxWidth,maxHeight)
MyFireworkBackSprite=CreateSprite(MyFireworkBackImage)
SetSpriteSize(MyFireworkBackSprite,maxWidth,maxHeight)
SetSpriteDepth(MyFireworkBackSprite,10000)
SetSpriteColorAlpha(MyFireworkBackSprite,100)
SetSpritePositionByOffset(MyFireworkBackSprite,maxWidth/2,maxHeight/2)
renderImg=CreateRenderImage (maxWidth,maxHeight,0,0)
ClearScreen()
repeat
SetRenderToImage (renderImg,0)
DrawSprite(MyFireworkBackSprite)
DrawSprite(fireBg)
for num=1 to maxNumberFireworks
if (fireFlag[num]=0) and random(1,100)<5 //a 5 percent chance of that particle being emitted
doFirework(num)
playSound(fireSound[num])
fireFlag[num]=1
UpdateParticles(num,0)
endif
if GetParticlesMaxReached(num)=1 //and GetParticlesMaxReached(num+100)=1
fireFlag[num]=0
endif
next num
Update(0)
Render()
setrendertoscreen ()
CreateSprite(350,renderImg)
SetSpriteSize(350,maxWidth,maxHeight)
Update(0)
Render()
swap()
until GetPointerPressed ( ) = 1
DeleteSprite(MyFireworkBackSprite)
DeleteImage(MyFireworkBackImage)
for num = 1 to maxNumberFireworks
DeleteParticles(num)
DeleteSound (fireSound[num])
next
SetRenderToImage (renderImg,0)
drawSprite(fireBg) //pastes a black sprite to buffer and screen
Update(0)
Render()
swap()
DeleteSprite(350)
DeleteSprite(fireBg)
setrendertoscreen ()
DeleteImage(renderImg)
endfunction
PK