Advertisement Jump to content
  • Advertisement
  • entries
  • comments
  • views

Particle System Screenshots + Videos + Code

Sign in to follow this  


Yay particle systems are fun...I havn't got to do one of these in a while. In addition to fixing all of the bugs/problems found in my recent multiplayer test, I'm adding a particle system into the game :-)

I'm going to post the code to the whole thing further down, you should be able to just drop the CParticleSystem class into whatever you want, if you're interested in using it. You'd just have to change my SpawnSprite function to however you display billboarded sprites.

Right now I've got support for 7 different particles/effects as follows: bullet casings, generic particles, basic explosions, fire, smoke, blood, etc.

I made 2 videos of the particle system, if you wanna check them out here are the links, any feedback would be appreciated....

//Videos are encoded in MPEG4
//Empty field test, 8MB

//In-game test, 12MB

Preview images:
//Screenshot from City_Particle.avi
//I'm not happy with the way the smoke is blending with the ground, anybody have ideas about how to fix that?? I can't just disable Z-testing.
//Maybe I could put a AABB around each particle and use that for collision detection, seems like overkill though.

//Another screenshot from City_Particle.avi

//Yea, I'm dead.

//View from up high

//Progressive screenshots of the "death beacon" that appears whenever a gang member dies, a beacon of that gang's color, emmits from their position.
//You can see it in motion in City_Particle.avi.

Here's the code to the particle system as in those videos/screenshots....hopefully somebody might get some use out of this, though it's pretty simple/straightforward. I spent a few hours typing, and a few hours tweaking the parms to get the different effects.

Notice there is no frustum culling on the particles. I do the culling on a particle emmitter basis, it's much more efficient that way. Since I'm already testing the visibility of any object/area that can emit a particle.

Finally here are some screenshots of each specific effect, taken from Particle_Test.avi I've still got a lot of work to do on the Explosion effect, it looks a lot better in motion/the video, as does the blood.

Code taken out because i'm tured of trying to get it to appear correctly.
I think there's something wrong with the 'Edit post' option on the journal also....I've had to delete/post this entry 2-3 times now.
Mainly because I couldn't edit it, and the tags were screwed up, plus there's no "Preview" option with the journal,
so there's no way to make sure they're right :-(


Early explosion (looks a lot better in motion)


Generic white particles (to show unit healing maybe?)

Shell casings imposters


Other than that, the game is coming along well I'm working on the gameplay/multiplayer aspects as's starting to come together.

- Dan
Sign in to follow this  


Recommended Comments

Yea...I'm pretty sure the edit post option is busted, in regard to journal posts at least...

Here's the fantastic source code to the particle system if anyone's interested ;-)

//GW_ParticleSystem.h, (c) 2006 Danny Green,


struct SParticle
bool m_Active; // If the particle is active or not.
unsigned char m_ParticleType; //Type of particle.
float m_Life; //Particle Life.
float m_FadeRate; // Fade Speed.
D3DXCOLOR m_Color; //Color of the particle.
D3DXVECTOR3 m_Position; //Position of the particle.
D3DXVECTOR3 m_Velocity; //Velocity of the particle.
D3DXVECTOR3 m_Gravity; //Gravity vector.
float m_Rotation; //Particles rotation.
float m_Scale; //Visual scale of the particle.

bool m_FadeColorFlag; //If the color should be faded.
bool m_RotateFlag; //If the particle rotates after it is spawned.
bool m_FadeAlphaFlag; //If the alpha should be faded

class CParticleSystem
CParticleSystem(void); //Default constructor.

~CParticleSystem(void); //Default destructor.

void Reset(void); //Resets the particle system

void Advance(float TimeStep); //Advances the particle system.

void AddParticle(D3DXVECTOR3 Position, D3DXCOLOR Color, D3DXVECTOR3 Speed, D3DXVECTOR3 Gravity, float Fade, unsigned char ParticleType, int ForceIndex, float Scale, bool FadeColor, bool FadeAlpha, bool Rotates); //Spawns a new particle.

SParticle m_Particles[MAX_PARTICLES]; //Particle structs.



//GW_ParticleSystem.cpp : Contains code for the particle system.
//(c) 2006 Danny Green,

#include "GW_Headers.h"
#include "GW_Externs.h"

float gParticleSpeedModifier = 0.4;

} //end of constructor

} //end of deconstructor

void CParticleSystem::Reset(void)
//Clear all particles
for(int i =0; i < MAX_PARTICLES; i++)
m_Particles[i].m_Active = false;
m_Particles[i].m_FadeColorFlag = false;
m_Particles[i].m_ParticleType = 0;
m_Particles[i].m_Life = 1.0;
m_Particles[i].m_FadeRate = 0;
m_Particles[i].m_Scale = 0;
m_Particles[i].m_Position.x = 0.0;
m_Particles[i].m_Position.y = 0.0;
m_Particles[i].m_Position.z = 0.0;
m_Particles[i].m_Color.r = 0;
m_Particles[i].m_Color.g = 0;
m_Particles[i].m_Color.b = 0;
m_Particles[i].m_Velocity.x = 0;
m_Particles[i].m_Velocity.y = 0;
m_Particles[i].m_Velocity.z = 0;
m_Particles[i].m_Gravity.x = 0;
m_Particles[i].m_Gravity.y = 0;
m_Particles[i].m_Gravity.y = 0;
} //end of for loop
} //end of Reset

double LastFired1 = 0, LastFired2 = 0;

void CParticleSystem::Advance(float TimeStep)
for(int k = 0; k < 1; k++)
AddParticle(D3DXVECTOR3(0,15,0), D3DCOLOR_ARGB(255,255,225,255), D3DXVECTOR3(-float((rand()%50)-26.0f)*2.1,float((rand()%50))*2.1,-float((rand()%50)-26.0f)*2.1), D3DXVECTOR3(0,-10.2,0), float(rand()%50)/5500.0f+0.005f, 1, -
  • Share this comment

    Link to comment
    Yeah today journal land is just busted. I had to delete and repost so many times because nothing was working and now I see millions of deleted entries and it is going to kill me because of my OCD. Also the journal titles are not showing up in the title bar anymore. There is some serious problems going down here. Other than that, great work as usual. Just thought I would share my pains as well.

    Share this comment

    Link to comment
    Are you using pointsprites (the d3d things) or are you manually creating textured quads in a dynamic vb?

    By the way, I think that your explosions can look way much better, by using other source/destination blending modes. Ages ago I started to make a game and the explosions looked like this

    I have to admit that the shape isn't very great, but I was quite happy with the color, I think that the explosions look really "hot" (like fire).

    Share this comment

    Link to comment
    Neat! How many FPS do you get while taking a video? The videos always seem to be played in fast-forward.

    Share this comment

    Link to comment
    Gaheris - Yea the game slows down to crap whenever I try to record a video, so I've got to go back and change the video's speed.

    I could capure a video no problem if I turn off FSAA, shadow maps, and reflections...but what's the fun in that? [grin]

    roel - You're right the explosions were very basic, I've got them figured out now, I'll have some screenshots in a few. I'm not using point sprites, just a dynamic VB.

    I hope the jornal posting/editing gets figured out.

    - Dan

    Share this comment

    Link to comment

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Advertisement

    Important Information

    By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

    Sign me up!