----------------------------------- Homer_simpson Sat Jan 03, 2009 6:01 pm Particle system for newbies(rain,snow,smoke,etc) ----------------------------------- i've seen that a lot of you like to make animations with turing, so here's a little tutorial on how you can incorporate a particle system into your animations. you could use it to make rain, snow,smoke,etc here's the steps to creating a particle system set a type for particles with its required attributes in this example we're going to setup a rain system meaning every drop of rain will be a particle. every drop of rain has a few attributes : x position, y position, falling speed so we declare: type Particle_Type : record x, y,speed : real end record now we need a lot of these particles so we declare an array of this type so we declare an array of a 100 particles: var Particles : array 1 .. 100 of Particle_Type now we have to give these particles their initial values : for i : 1 .. 100 Particles (i).x := Rand.Int (0, maxx) %randmize the x position of rain droplets from 0 to maxx Particles (i).y := Rand.Int (0, maxy) %randmize the y position Particles (i).speed := Rand.Int (3, 5) %randmize the speed of drops rain end for after we've setup all of our particles it's time to move them and draw them so we start our animation loop like so: loop move particles draw particles check to see if the particles need to be renewed clear the screen end loop in code: loop %main animation loop cls %clear the screen for i : 1 .. MaxParticles %inside this loop we go through all the particles 1 by 1 Particles (i).y -= Particles (i).speed %move down the drop of rain if Particles (i).y