Type TwoDParticle
x as Integer
y as Integer
Colour as Dword
Frequency as Integer
Radius as Integer
Circular as Boolean
EndType
Dim TwoDParticle(0) as TwoDParticle
NumParticles = 100
Dim MyArray(NumParticles) as Integer
For i = 1 to NumParticles
MyArray(i) = MakeTwoDParticle(rnd(640),rnd(480),rgb(rnd(255),rnd(255),rnd(255)),rnd(40),rnd(20),rnd(1))
Next i
Do
Cls
Text 0,0,Str$(Screen FPS())
Text 0,20,Str$(NumParticles)
For i = 1 to NumParticles
PlayTwoDParticle(MyArray(i))
Next i
If Spacekey() = 1 and s = 0
Inc NumParticles
s = 1
Array Insert At Bottom MyArray(0)
MyArray(NumParticles) = MakeTwoDParticle(rnd(640),rnd(480),rgb(rnd(255),rnd(255),rnd(255)),rnd(40),rnd(20),rnd(1))
Endif
If Spacekey() = 0 then s = 0
Loop
Function MakeTwoDParticle(x,y,Colour as Dword,Frequency,Radius,Circular as Boolean)
Array Insert At Bottom TwoDParticle(0)
Number = Array Count(TwoDParticle(0))
TwoDParticle(Number).x = x
TwoDParticle(Number).y = y
TwoDParticle(Number).Colour = Colour
TwoDParticle(Number).Frequency = Frequency
TwoDParticle(Number).Radius = Radius
TwoDParticle(Number).Circular = Circular
Endfunction Number
Function PlayTwoDParticle(Number)
Lock Pixels
For i = 1 to TwoDParticle(Number).Frequency
If TwoDParticle(Number).Circular = 1
Angle = Rnd(360)
Dot TwoDParticle(Number).x+Cos(Angle)*Rnd(TwoDParticle(Number).Radius),TwoDParticle(Number).y+Sin(Angle)*Rnd(TwoDParticle(Number).Radius),TwoDParticle(Number).Colour
Else
Dot (TwoDParticle(Number).x-TwoDParticle(Number).Radius)+Rnd(TwoDParticle(Number).Radius*2),(TwoDParticle(Number).y-TwoDParticle(Number).Radius)+Rnd(TwoDParticle(Number).Radius*2),TwoDParticle(Number).Colour
Endif
Next i
Unlock Pixels
Endfunction
Okay they are not great particles, but they are very fast (I get 250+ at 100 FPS on my PC) and have a nice retro feel too them.
Try playing around with the numparticles variable.