Anyone wanting a no frills experience with Particle Effects and in a bit of a hurry, because most people that read this from time to time would have guessed it but I thought this one could use a little explaining and how this came about. This was POC code a few weeks back, and it was originally part of Luna (not yet public). This means its not finished and that is why it currently has one mode. Here is what one of the longest tut programs would look like if you commented almost every single line for a tutorial... But then again, its aimed for more advanced users.
If there are any questions/comments, please leave a comment or whatever. Just some insight on what I've been doing lately. So far I've tested it with 8000 particles and a 128x128 particle, cpu usage < 105MHZ and ~6mb ram Tested on (Windows XP 32 bit, Windows 7 x64, ubuntu 10.10 x64 and ubuntu 11.04 x64). Enjoy.
Code:
Code:
program ParticleFX;
uses
Prometheus_Vid,
crt; //we need the delay() from here only... i should make one in prometheus ;)
var
PE: ParticleEffect;
begin
//All our usual Prometheus Init code
PrometheusVid_Start();
CreateWindow(640, 480, 32);
UpdateWindow();
UpdateCanvas();
//Now lets set up this particle effect: (there are a lot of values to define)
PE.LoadParticleImageFromFile('Particle_Fire.png'); //We load our particle from the file Particle_Fire.png
PE.DurationRange[1] := 200; //Each particle will at least last for 200 Update Cycles
PE.DurationRange[2] := 570; // To a maximum of 570 update cycles
PE.ParticleEffectMode := ParticleFX_RadialFromCentre; //The particle effect mode/name of how to manage particles
PE.Particles := 3000; //How many particles we want on screen at a time
PE.SetParticleEffectArea(-1000, -1000, 1000, 1000); //Consider a particle 'dead' / invisible if it exceeds these screen co-odinates
PE.VelocityRange[1] := 1; //Each particle has a minimum velocity of 1 diagonal pixel per update cycle
PE.VelocityRange[2] := 4; // To a maximum speed of 4 diagonal pixels
PE.OrientationRange[1] := 0; //Each particle has a direction (bearing) of at least 000 (This is a bit buggy, fixing...)
PE.OrientationRange[2] := 360; //to a maximum bearing of 360 (basically any direction)
PE.EffectLength := 50000; //The particle effects itself stops entirely after 50,000 update cycles (a lot!)
PE.StartX := 320; //The starting point of the particle effect (x)
PE.StartY := 240; //The starting point of the particle effect (y)
PE.Respawn := True; //When a particle dies, make a new one from the centre with ne velocity, orientation, life & etc
PE.Activate; //Inits everything and starts the effect
repeat
ClearCanvas(); //Clear the screen
PE.Update(); //Let the particle effect stop if ended and etc...
PE.Draw(); //Draws the particles on the screen and controls them
UpdateCanvas(); //'Flip' data onto the screen
delay(50); //give the OS some time
until PE.Running = False; //When the particle effect is done PE.Update sets this to false for you
end.
I tried publishing it in articles, but I figured thanks to WILL that it's best be suited here. The way things are going I'm going to need to brush up my SF page to host all this. PGD would be in real danger of becoming PDS (prometheus demo show )
Some presets for effects:Explosion ring thing: fast velocity, no respawn, all equal velocity. gives ring of particles
Flying towards a star/through stuff: the example preset
Flame style thing: Narrow angle and enjoy.
Bookmarks