FN.DEF Burst(l, t, tmax) ! l= list of points ! tmax= points life time ! t= variable to help tmax LIST.SIZE l, sz IF --t FOR n=1 TO sz STEP 5 LIST.GET l, n, x LIST.GET l, n+1, y LIST.GET l, n+2, incx LIST.GET l, n+3, incy LIST.GET l, n+4, obj LET x+= incx LET y+= incy LIST.REPLACE l, n, x LIST.REPLACE l, n+1, y GR.MODIFY obj,~ "x", x,~ "y", y,~ "alpha", 255*(t/tmax) NEXT FN.RTN t ELSE FOR n=5 TO sz STEP 5 LIST.GET l, n, obj GR.HIDE obj NEXT FN.RTN 0 ENDIF FN.END GR.OPEN 255,0,0,0,0,1 GR.SET.ANTIALIAS 0 GR.SCREEN sw,sh !! LET rel_x= sw/500 LET rel_y= sh/800 GR.SCALE rel_x, rel_y LET sw= 500 LET sh= 800 !! LET maxp= 50 % number of points per fireworks LET maxFires= 3 % number of fireworks at same time LET ppl= 5 % points per layer (min 2, max 6) LET maxSize= sw/100 LET maxSpeed= MIN(sw,sh)/500 DIM t[maxFires] LET t1= 40 LET t2= t1/2 DIM tmax[maxFires] DIM l[maxFires] DIM Pt[maxp*maxFires] FOR n=1 TO maxFires LIST.CREATE N,l[n] NEXT GR.COLOR 255, RND()*255, RND()*255, RND()*255, 1 FOR n=1 TO maxp*maxFires GR.POINT Pt[n],sw/2,sh/2 GR.HIDE Pt[n] NEXT GR.RENDER WAKELOCK 3 !--------- MAIN ------------ DO FOR n=1 TO maxFires IF !t[n] ! IF l[n] THEN ! LIST.PtEAR l[n] LET t[n]= INT(RND()*t1)+t2 LET tmax[n]= t[n] LET p_camada= INT(RND()*ppl+2) LET np= INT(maxp/p_camada)*p_camada LET x= 100+RND()*(sw-200) LET y= 100+RND()*(sh-200) GOSUB CreateFireWork ELSE LET t[n]= Burst(l[n], t[n], tmax[n]) ENDIF NEXT GR.RENDER UNTIL 0 CreateFireWork: ! np= number of points ! p_camada= points per layer LET b= 0 LET nPt= (n-1)*maxp+1 LIST.clEAR l[n] FOR i=1 TO np/p_camada LET b+= maxSpeed LET a1= (RND()*(360/p_camada)) LET a2= (360/p_camada) LET r= RND()*maxSize+1 GR.COLOR 255, RND()*255, RND()*255, RND()*255, 1 GR.SET.STROKE r GR.PAINT.GET myPaint FOR nn= 1 TO p_camada LET a= TORADIANS(a1) LET a1+= a2 LET incx= SIN(a)*b LET incy= COS(a)*b GR.SHOW Pt[nPt] GR.MODIFY Pt[nPt],~ "x", x,~ "y", y,~ "paint", myPaint LIST.ADD l[n],x, y, incx, incy, Pt[nPt++] NEXT NEXT RETURN END