Hi all 😀
I finally got some time to make something so to get back into Engine Basic mode I made this simple particle demo. Just use the Z & X keys for Particle amount and the Arrow keys to change gravity and particle spread.
1 'Particle Demo by Anthony Clarke
5 CLS
6 partNum=512:partSpread=0.85
10 DIM particle(partNum,6): '0=exist 1=x 2=y 3=xspeed 4=yspeed
20 gravity=0.04:originx=(PSIZE(0)/2):originy=(PSIZE(1))
22 col=RGB(RND(255),RND(255),RND(255))
24 yspeed=2
29 f=FRAME()
30 &main
40 DO
42 CLS
45 GOSUB &hud
50 GOSUB &addPart
60 GOSUB &drawParticle
70 GOSUB &updateParticle
80 GOSUB &control
490 VSYNC f+2
495 f=f+2
500 LOOP
1000 &addPart
1010 FOR i=0 TO partNum-1
1020 IF particle(i,0)=0 THEN
1030 particle(i,0)=1
1040 particle(i,1)=originx
1050 particle(i,2)=originy
1052 particle(i,3)=((RND(0)-RND(0))*partSpread)*2
1054 particle(i,4)=((yspeed-RND(0)))*2
1058 particle(i,5)=RGB(RND(220)+35,RND(220)+35,RND(220)+35)
1070 ENDIF
1080 NEXT i
1990 RETURN
2000 &drawParticle
2010 FOR i=0 TO partNum-1
2020 IF particle(i,0)=1 THEN
2030 PSET particle(i,1),particle(i,2),particle(i,5)
2040 ENDIF
2050 NEXT i
2060 RETURN
3000 &updateParticle
3010 FOR i=0 TO partNum-1
3020 IF particle(i,0)=1 THEN
3030 particle(i,1)=particle(i,1)+particle(i,3)
3040 particle(i,2)=particle(i,2)-particle(i,4)
3045 particle(i,4)=particle(i,4)-gravity
3050 IF particle(i,2)>PSIZE(1) THEN
3060 particle(i,0)=0
3070 ENDIF
3080 ENDIF
3090 NEXT i
3100 RETURN
4000 &hud
4010 GPRINT 0,0,"Particles: ";partNum;" ";"Gravity: ";gravity;" ";"Spread: ";partSpread;" ";"Z,X & Arrow Keys";
5000 RETURN
5500 &control
5510 UPkey=KEY(25)
5520 DOWNkey=KEY(27)
5530 LEFTkey=KEY(24)
5540 RIGHTkey=KEY(26)
5542 PLUSkey=KEY(107)
5543 PLUSkey2=KEY(90)
5545 MINUSkey=KEY(109)
5547 MINUSkey2=KEY(88)
5550 IF UPkey=1 THEN
5560 gravity=gravity*0.95
5570 ELSE IF DOWNkey=1 THEN
5580 gravity=gravity*1.05
5590 ELSE IF LEFTkey=1 THEN
5600 partSpread=partSpread*0.95
5610 ELSE IF RIGHTkey=1 THEN
5620 partSpread=partSpread*1.05
5630 ELSE IF PLUSkey=1 OR PLUSkey2=1 THEN
5640 partNum=partNum+1
5650 ELSE IF MINUSkey=1 OR MINUSkey2=1 THEN
5660 partNum=partNum-1
5662 particle(partNum+1,0)=0
5670 ENDIF
5700 IF partNum<1 THEN partNum=1
5710 IF gravity>0.2 THEN gravity=0.2
5720 IF partNum>511 THEN partNum=511
5730 IF partSpread<0.02 THEN partSpread=0.02
5740 IF partSpread>10 THEN partSpread=10
5745 IF gravity<0.002 THEN gravity=0.002
6010 RETURN