hey, just knocked this together very quickly. This is a VERY basic example of a particle engine.
the way i see it is, it works by creating a type, with say 50 objects. each object has
the point it starts at,
a speed at which it travels at,
a set distance or time it travels for that speed at
and each also has a fade, to make it look better
this applies only to my system below, as i say, there is much better particle engines out there.
i used low poly spheres so i could post the code and it could run on anyone computer with blitz.
Most people use sprites with say a firey looking texture if they were doing a particle engine for fire.
other links you should check out
norcs particle engine
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=norc02062003164813&comments=no
hope some of this helps :D
the way i see it is, it works by creating a type, with say 50 objects. each object has
the point it starts at,
a speed at which it travels at,
a set distance or time it travels for that speed at
and each also has a fade, to make it look better
this applies only to my system below, as i say, there is much better particle engines out there.
i used low poly spheres so i could post the code and it could run on anyone computer with blitz.
Most people use sprites with say a firey looking texture if they were doing a particle engine for fire.
Graphics3D 800,600; set graphics mode SetBuffer BackBuffer(); set to double buffering light=CreateLight(); create a light camera=CreateCamera(); create a camera PositionEntity camera,0,5,-13; and position it back from the particles cube=CreateSphere(2); create the low poly sphere for the particles to copy PositionEntity cube,-50,0,0; position it out of view EntityColor cube,255,20,20; change the color to red Gosub setup; goto the type setup subroutine (not really needed) timer=30; the time in milliseconds in which the next particle will be generated, the lower the number the more that will be generated timer1=MilliSecs() While Not KeyHit(1) If MilliSecs()>timer1+timer Then Gosub createparticle; if the timer reaches 100 milliseconds then goto the createnewparticle sub-routine. then reset the timer timer1=millisecs() end if Gosub updateparticles; update the particles ie, move them UpdateWorld() RenderWorld() Flip Wend End .updateparticles For p.particle=Each particle; cycle thru all the available type objects p\y=p\y+p\speed; move the particle upwards according to it's speed EntityAlpha p\entity,(p\distance-p\y)/p\distance; fade the entity as it comes to the end of it's distance PositionEntity p\entity,p\x,p\y,0; position the entity on screen in it's updated place If p\y>p\distance Then FreeEntity p\entity:Delete p.particle; if the entity reaches its max distance then free the entity and delete the type object ;(ALWAYS FREE THE ENTITY FIRST) Next Return .createparticle p.particle=New particle; create a new type object p\entity=CopyEntity(cube); copy the cube entity into the type object p\y=0 p\x=Rnd(-3,3); set a random x position p\speed=Rnd(0.01,0.9); set the speed the particle will travel at p\distance=Rnd(2,15); set the max distance the particel can travel Return .setup Type particle; set up the type fields Field entity Field x#,y# Field speed# Field distance# End Type Return
other links you should check out
norcs particle engine
http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=norc02062003164813&comments=no
hope some of this helps :D