Yeah it does, you just have to play with the scaling and frequency to get the best results you can. Also turn off the bounce# value and you regain a bit of speed. Another factor is the fading, if you turn down the Life# and put the final fade value up a bit, you can get the same effect with more fps
e.g. To show the effect playing has, I gained 60-70 fps with this code
Rem Project: Particle System
Rem Created: 19/04/2005 00:48:01
Rem ***** Main Source File *****
` Particles Demo `
` ============== `
cls
autocam off
position camera 0,20,-160
point camera 0,0,0
`Floor`
make object box 1,100,0.01,100
load image "floor.jpg",2
texture object 1,2
`Sky`
make object sphere 2,1000
set object cull 2,0
load image "sky.jpg",4
texture object 2,4
` Ok first we load the system`
Gosub PSystemSetup
` Then we load an image for the flame `
Load image "Flame.bmp",1
` and one for smoke`
Load image "smoke.bmp",3
`Now we shal make the fire however there are some principles to learn first`
`We have a two types of particles, 'standard' and 'object' particles`
`To make a standard particle we use the 'MakeParticle' command and for
`object particles we use the MakeObjectParticle.
`Standard particles are just plains that face the camera but object particles`
`Are actual objects e.g. cubes, spheres, even memblocks can be loaded using `
`this command`
` We also have access to 'Particle Sources', as you can imagine having to always
` think about making particles for a fire for instance, would be dull, this command
` takes care of it for you and I shal now show you how:
` My functions have a rediculous number of paramaters but they are useful so enjoy !
` MakeParticleSource(Num, Freq, LTO, x#, y#, z#, xvar, yvar, zvar, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, XAccel#, YAccel#, ZAccel#, Bounce#, StartTex, Endtex, Rotate, Zwrit)
` Num: Is the source number, just like we refer to objects with a number we also do with sources.
` Freq: The frequency of that particles, how many times a second a particle is made
`
` LTO : LockToObject- this allows you to attach a source to an object, i use this for trails from my rockets!
` it means wherever the object moves the particle source will follow without your help
` all you put in this section is the number of the object to attach to.
`
` x#,y#,z#: Quite simply where you want to put the source
`
` xvar, yvar, zvar: This ses how wide the source is, a particle can appear anywhere in this given area
` The point of these variables is say we make a fire, now fire doesnt appear from one
` spot, it is spread out, so this emulates that as you shall see soon.
`
` Life#: The ammount of time in seconds that the particles last from the source
`
` StartSize#: Particles are square so we set the width and height they start as with this variable
` Endsize: Self explanatory, after the time specified in life, how big should the particle be.
`
` Ghost: This sets ghosting on, very useful in these effects !
`
` Startfade#: The Fading the particle starts with..
` Endfade#: and the fading it ends with
`
` XSpeed#, YSpeed#, ZSpeed#: The starting speed of the particle
` XAccel#, YAccel#, ZAccel#: How much speed each particle gains each second
`
` Bounce#: If this is on, if the particle collides with an object it will relfect off. A very clever function
` that allows for very realistic smoke
`
` StartTex, Endtex: Set both of these as your image for the particles, it is meant to be able to take a range so
` That it would actualy animate the particles, however this feature was never finished
`
` Rotate: Set this on if you want the particles to be rotated randomly at creation, it helps by giving a less
` uniform look to particles
`
` Zwrit: Disable Zwriting on or off, if you are creating fire or smoke youll want it disabled.
`Ok so lets use that knowledge !
Num=1 :`Number of the source
Freq=9 :` particles created 14 times a second
LTO=0 :` not locked to any objects
x#=0 :`
y#=0 :`
z#=0 :`
xvar=9 :` width of fire =9
yvar=0 :` height of fire =0, all the particles start at the same height
zvar=9 :` depth of fire =9
Life#=1 :` paritcles last 1 second
StartSize#=20 :` particles made 20x20 pixels
Endsize#=4 :` particles end 4x4 pixels
Ghost=1 :` particles are ghosted
StartFade#=200 :` 200% fading, so particles start bright
Endfade#=30 :` ends at 30%
XSpeed#=0 :`no starting speed
YSpeed#=0 :`no starting speed
ZSpeed#=0 :`no starting speed
XAccel#=0 :`
YAccel#=30 :` accelerating at 30 a second
ZAccel#=0 :`
Bounce#=0 :` particles do not react with objects
StartTex=1 :` image number
Endtex=1 :` has to be same as above
Rotate=1 :` rotate the particles
Zwrit=1 :` disable zwrite
MakeParticleSource(Num, Freq, LTO, x#, y#, z#, xvar, yvar, zvar, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, XAccel#, YAccel#, ZAccel#, Bounce#, StartTex, Endtex, Rotate, Zwrit)
`
`and how about another one, this time not explained but its for the smoke, see if you can work it out.
MakeParticleSource(2, 6, 0, x#, y#, z#, 6, yvar, 6, 6, 5, 30, 1, 80, 40, XSpeed#, 1, ZSpeed#, XAccel#, 5, ZAccel#, 0.6, 3, 3, 1, 1)
`
` Youll see i set bounce to 0.6 in the smoke source...unrem this code to see what it does
make object sphere 3,50
position object 3,20,50,0
load image "Balltex.jpg",5
texture object 3,5
setupobject 3,0,0 : `This line is essential, it is how the program sets up collision.
` Clever huh !?
`
`Here is the main loop`
Do
FPS#(1)=(1.0/screen fps())
UpdateParticleSource()
UpdateParticles()
text 10,10,str$(screen fps())
sync
loop
PSystemSetup:
Type ParticleSourceDetail
Frequency as float
Last as float
LTO as integer
X as float
Y as float
Z as float
Xvar as float
Yvar as float
Zvar as float
Life as float
StartSize as float
Endsize as float
Ghost as boolean
StartFade as float
Endfade as float
XSpeed as Float
YSpeed as Float
ZSpeed as Float
Xaccel as Float
Yaccel as Float
Zaccel as Float
Bounce as Float
StartTex as integer
Endtex as integer
Rotate as boolean
Zwrit as boolean
Endtype
Type ParticleDetail
Life as float
Lfar as float
Size as float
Growth as Float
Fade as Float
FadeRate as Float
XSpeed as Float
YSpeed as Float
ZSpeed as Float
Xaccel as Float
Yaccel as Float
Zaccel as Float
Bounce as Float
StartTex as integer
Endtex as integer
Curtex as integer
Pointo as float
Killto as string
Damage as float
Spin as float
Endtype
Dim Particles(100) as ParticleDetail
Dim ParticleSource(20) as ParticleSourceDetail
Dim FPS#(5)
null=make vector3(1)
null=make vector3(2)
null=make vector3(3)
return
`===========`
` GFX `
`===========`
Function UpdateParticleSource()
for num=1 to 20
if ParticleSource(Num).Frequency>0
Frequency = ParticleSource(Num).Frequency
Last = ParticleSource(Num).Last
LTO = ParticleSource(Num).LTO
x# = ParticleSource(Num).X
y# = ParticleSource(Num).Y
z# = ParticleSource(Num).Z
xvar = ParticleSource(Num).Xvar
yvar = ParticleSource(Num).Yvar
zvar = ParticleSource(Num).Zvar
Life# = ParticleSource(Num).Life
StartSize# = ParticleSource(Num).StartSize
Endsize# = ParticleSource(Num).Endsize
Ghost = ParticleSource(Num).Ghost
StartFade# = ParticleSource(Num).StartFade
Endfade# = ParticleSource(Num).Endfade
XSpeed# = ParticleSource(Num).XSpeed
YSpeed# = ParticleSource(Num).YSpeed
ZSpeed# = ParticleSource(Num).ZSpeed
Xaccel# = ParticleSource(Num).Xaccel
Yaccel# = ParticleSource(Num).Yaccel
Zaccel# = ParticleSource(Num).Zaccel
Bounce# = ParticleSource(Num).Bounce
StartTex = ParticleSource(Num).StartTex
Endtex = ParticleSource(Num).Endtex
Rotate = ParticleSource(Num).Rotate
Zwrit = ParticleSource(Num).Zwrit
ParticleSource(Num).Last=ParticleSource(Num).Last+FPS#(1)
if ParticleSource(Num).Last>ParticleSource(Num).Frequency
if LTO>0
if object exist(LTO)=1
x#=(object position x(LTO)+x#)
y#=(object position y(LTO)+y#)
z#=(object position z(LTO)+z#)
else
DeleteParticleSource(num)
endif
endif
x#=x#+(rnd(Xvar)-(Xvar/2))
y#=y#+(rnd(Yvar)-(Yvar/2))
z#=z#+(rnd(Zvar)-(Zvar/2))
MakeParticle(x#, y#, z#, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, Xaccel#, Yaccel#, Zaccel#, Bounce#, StartTex, Endtex, Rotate,1, Zwrit)
ParticleSource(Num).Last=0
endif
endif
next num
Endfunction
Function MakeParticleSource(Num,Frequency,LTO, x#, y#, z#, xvar, yvar, zvar, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, XAccel#, YAccel#, ZAccel#, Bounce#, StartTex, Endtex, Rotate, Zwrit)
ParticleSource(Num).Frequency = (1.0/Frequency)
ParticleSource(Num).Last = 0
ParticleSource(Num).LTO = LTO
ParticleSource(Num).X = x#
ParticleSource(Num).Y = y#
ParticleSource(Num).Z = z#
ParticleSource(Num).Xvar = xvar
ParticleSource(Num).Yvar = yvar
ParticleSource(Num).Zvar = zvar
ParticleSource(Num).Life = Life#
ParticleSource(Num).StartSize = StartSize#
ParticleSource(Num).Endsize = Endsize#
ParticleSource(Num).Ghost = Ghost
ParticleSource(Num).StartFade = StartFade#
ParticleSource(Num).Endfade = Endfade#
ParticleSource(Num).XSpeed = XSpeed#
ParticleSource(Num).YSpeed = YSpeed#
ParticleSource(Num).ZSpeed = ZSpeed#
ParticleSource(Num).Xaccel = Xaccel#
ParticleSource(Num).Yaccel = Yaccel#
ParticleSource(Num).Zaccel = Zaccel#
ParticleSource(Num).bounce = Bounce#
ParticleSource(Num).StartTex = StartTex
ParticleSource(Num).Endtex = Endtex
ParticleSource(Num).Rotate = Rotate
ParticleSource(Num).Zwrit = Zwrit
Endfunction
Function DeleteParticleSource(num)
ParticleSource(Num).Frequency=0
Endfunction
Function FreeParticleSource()
for num=1 to 20
if ParticleSource(Num).Frequency=0 then result=num
next num
Endfunction result
Function MakeParticle(x#, y#, z#, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, XAccel#, YAccel#, ZAccel#, Bounce#, StartTex, Endtex, Rotate, Pointo, Zwrit)
Freepar=FindFreeOb(451,550)
if freepar>0
fa=freepar-450
Particles(fa).Life = Life#
Particles(fa).Lfar = 0
Particles(fa).Size = 100
Particles(fa).Growth = (((100/StartSize#)*Endsize#)/Life#)
Particles(fa).Fade = StartFade#
Particles(fa).FadeRate = (Endfade#-StartFade#)/Life#
Particles(fa).XSpeed = XSpeed#
Particles(fa).YSpeed = YSpeed#
Particles(fa).ZSpeed = ZSpeed#
Particles(fa).Xaccel = Xaccel#
Particles(fa).Yaccel = Yaccel#
Particles(fa).Zaccel = Zaccel#
Particles(fa).bounce = Bounce#
Particles(fa).StartTex = StartTex
Particles(fa).Endtex = Endtex
Particles(fa).CurTex = StartTex
Particles(fa).Pointo = Pointo
Particles(fa).damage = 0
Particles(fa).spin = 0
if Endsize#<StartSize# then Particles(fa).Growth=((100-((100/StartSize#)*Endsize#))/Life#)*-1
Make object plain freepar,Startsize#,Startsize#
position object freepar, x#, y#, z#
texture object freepar,StartTex
if rotate=1
rotate object freepar,0,0,0
zrotate object freepar,rnd((36000/100.0))
fix object pivot freepar
endif
if Ghost=1 then ghost object on freepar
Fade object freepar,StartFade#
set object cull freepar,0
set object transparency freepar,4
if Zwrit=1 then DISABLE OBJECT ZWRITE freepar
endif
endfunction
Function MakeObjectParticle(name$,x#, y#, z#, Life#, StartSize#, Endsize#, Ghost, StartFade#, Endfade#, XSpeed#, YSpeed#, ZSpeed#, XAccel#, YAccel#, ZAccel#, Bounce#, StartTex, Endtex, Rotate, pointo, Zwrit)
Freepar=FindFreeOb(451,550)
if freepar>0
fa=freepar-450
Particles(fa).Life = Life#
Particles(fa).Lfar = 0
Particles(fa).Size = 100
Particles(fa).Growth = 0
Particles(fa).Fade = StartFade#
Particles(fa).FadeRate = (Endfade#-StartFade#)/Life#
Particles(fa).XSpeed = XSpeed#
Particles(fa).YSpeed = YSpeed#
Particles(fa).ZSpeed = ZSpeed#
Particles(fa).Xaccel = Xaccel#
Particles(fa).Yaccel = Yaccel#
Particles(fa).Zaccel = Zaccel#
Particles(fa).bounce = Bounce#
Particles(fa).StartTex = StartTex
Particles(fa).Endtex = Endtex
Particles(fa).CurTex = StartTex
Particles(fa).Pointo = pointo
Particles(fa).damage = 0
Particles(fa).spin = 0
if name$="*cube" or name$="*sphere" or left$(name$,6)="*memb-"
if name$="*cube" then Make object cube freepar,StartSize#
if name$="*sphere" then Make object sphere freepar,StartSize#
yrotate object freepar,Pointo
else
Load object name$,freepar
scale object freepar,startsize#,startsize#,startsize#
endif
position object freepar, x#, y#, z#
if left$(name$,6)<>"*memb-" then texture object freepar,StartTex
if rotate=1
rotate object freepar,0,0,0
zrotate object freepar,rnd((36000/100.0))
fix object pivot freepar
endif
if Ghost=1 then ghost object on freepar
Fade object freepar,StartFade#
set object cull freepar,0
set object transparency freepar,4
if Dwrit=1 then DISABLE OBJECT ZWRITE freepar
endif
endfunction
Function UpdateParticles()
For i=451 to 550
if object exist(i)=1
if object screen x(i)>1024 or object screen x(i)<0 or object screen y(i)>768 or object screen y(i)<0
` if object visible(i)=1 then exclude object on i
else
`if object visible(i)=0 then exclude object off i
endif
fa=i-450
Particles(fa).Lfar=Particles(fa).Lfar+(1*FPS#(1))
if Particles(fa).Endtex<>Particles(fa).Starttex
diff=((Particles(fa).Endtex-Particles(fa).Starttex)+1)
lsplit#=Particles(fa).Life/diff
prog#=Particles(fa).Lfar
spnum=0
repeat
spnum=spnum+1
prog#=prog#-lsplit#
until prog#<0
spnum=((Particles(fa).Starttex-1)+spnum)
if spnum<>Particles(fa).Curtex then texture object i,spnum : Particles(fa).curtex=spnum
endif
Particles(fa).Size=Particles(fa).Size+(Particles(fa).Growth*FPS#(1))
Scale object i,Particles(fa).Size,Particles(fa).Size,Particles(fa).Size
Particles(fa).Fade=Particles(fa).Fade+(Particles(fa).FadeRate*FPS#(1))
Fade Object i,Particles(fa).Fade
Particles(fa).XSpeed=Particles(fa).XSpeed+(Particles(fa).XAccel*FPS#(1))
Particles(fa).YSpeed=Particles(fa).YSpeed+(Particles(fa).YAccel*FPS#(1))
Particles(fa).ZSpeed=Particles(fa).ZSpeed+(Particles(fa).ZAccel*FPS#(1))
` The bouncing bit `
`------------------`
if Particles(fa).bounce>0
hit=IntersectObject(0, 0, object position x(i), object position y(i), object position z(i), (object position x(i)+(Particles(fa).XSpeed*FPS#(1))), (object position y(i)+(Particles(fa).YSpeed*FPS#(1))), (object position z(i)+(Particles(fa).ZSpeed*FPS#(1))),0)
if hit>0
set vector3 1,Particles(fa).XSpeed,Particles(fa).YSpeed,Particles(fa).ZSpeed
set vector3 2,GetCollisionNormalX(),GetCollisionNormalY(),GetCollisionNormalZ()
Reflect(1,2)
speed#=length vector3(1)
normalize vector3 1,1
scale vector3 1,1,(speed#*Particles(fa).bounce)
Particles(fa).XSpeed=x vector3(1)
Particles(fa).YSpeed=y vector3(1)
Particles(fa).ZSpeed=z vector3(1)
endif
endif
`------------------`
` Spinning
`------------------`
if Particles(fa).spin>0.01
rotate object i,0,0,0
zrotate object i,Particles(fa).spin
fix object pivot i
endif
`------------------`
Position object i,(object position x(i)+(Particles(fa).XSpeed*FPS#(1))),(object position y(i)+(Particles(fa).YSpeed*FPS#(1))),(object position z(i)+(Particles(fa).ZSpeed*FPS#(1)))
if Particles(fa).Pointo=1 then point object i,camera position x(),camera position y(),camera position z()
if Particles(fa).Lfar=>Particles(fa).Life then delete object i
endif
holdpar=0
killpar=0
next i
endfunction
Function FindFreeOb(rangemin,rangemax)
Free=0
For i=rangemin to rangemax
if object exist(i)=0 and Free=0 then Free=i
if Free>0 then i=rangemax
next i
Endfunction Free
Function Reflect(vector,normal)
dot#=dot product vector3(vector,normal)
dot#=(dot#*2.0)
multiply vector3 Normal,dot#
subtract vector3 vector,vector,Normal
endfunction
Function IgnoreMe()
make memblock 1,1
delete memblock 1
Endfunction
I only made a few changes and although you can tell the difference it defiantely is faster.
Just play and find your balance between speed and realism !
Enjoy, also try putting other particle images on, it really can make some cool effects.