PARTICLE ENGINE
BlitzPlus Forums/BlitzPlus Programming/PARTICLE ENGINE
| ||
Hi people, i can't seem to find any (beginner level) easy-to-follow tutorials about how to write a particle engine. Please, could somebody possibly show me an easy to understand, well commented piece of particle code, even if it means just having 3 particles on the screen. This would help me out so much as it's been so frustrating to find any easy tutorials on the use of particles. Thanks guys BLUE :) |
| ||
you could try figuring this one out (code archives) |
| ||
Check this out. Very simple example of using particles for explosions.Graphics 800,600 SetBuffer BackBuffer() Type particle Field x#,y# Field speed# Field angle# Field time Field timer End Type While Not KeyHit(1) Cls If MouseHit(1) Then For loop=1 To (Int(Rnd(25,49))) create_particles(MouseX(),MouseY()) Next End If update_particle() Rect MouseX(),MouseY(),2,2 Flip Wend End Function create_particles(x,y) p.particle=New particle p\angle=Rnd(0,359) p\x=x p\y=y p\speed=Rnd(0.2,1.3) p\time=MilliSecs()+Int(Rnd(500,3000)) End Function Function update_particle() For p.particle=Each particle Color Int(Rnd(20,250)),Int(Rnd(50,250)),Int(Rnd(50,250)) Rect p\x,p\y,1,1 p\x=p\x+(Sin(p\angle)*p\speed) p\y=p\y+(Cos(p\angle)*p\speed) If MilliSecs()>=p\time Then Delete p.particle End If Next End Function |
| ||
Yes, this seems to have done the trick :). Thanks very much guys, i really appriciate the help. Now i can start on my particle engine :). Thanks again BLUE |