mod_base_partsys.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
00009  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00010  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00011  *****************************************************************************/
00012 
00013 #if COMPILING_MODULE
00014 #ifndef MOD_BASE_PARTSYS_HH
00015 #define MOD_BASE_PARTSYS_HH 1
00016 
00017 #include "eng_sprite.hh"
00018 
00019 namespace mod_base {
00020 
00021 class ParticleSystem;
00022 
00026 class Particle : public Sprite
00027 {
00028 
00029 friend class ParticleSystem;
00030 public:
00031                     Particle( const WorldVertex& pos, const fp width,
00032                               Sprite::Textures textures, const RGBA color,
00033                               const Milliseconds lifetime );
00034     virtual         ~Particle();
00035     virtual void    Animate( void ) { }
00036 
00037 protected:
00038     Milliseconds    mTimeOfDeath;   
00039 public:
00040     
00041 };
00042 
00056 class ParticleSystem
00057 {
00058 
00059 public:
00060                 ParticleSystem( void );
00061                 ~ParticleSystem();
00062     void        Add( SharedPtr<Particle> particle, const Milliseconds lifetime );
00063 
00064 private:
00065     void        Tick( const Milliseconds millisecElapsed );
00066 
00067 private:
00071     class TimerFunctor : public Timer::Functor
00072     {
00073     public:
00074         TimerFunctor( ParticleSystem& partsys ) : mParticleSystem(partsys) { }
00075         void operator()( const Milliseconds millisecElapsed );
00076     private:
00077         ParticleSystem& mParticleSystem;
00078     };
00079 
00080 private:
00081     typedef list<SharedPtr<Particle> > Particles;
00082     Particles               mParticles;
00083     shptr<TimerFunctor>     mTimerFunctor;      
00084 };
00085 
00086 } // namespace mod_base
00087 
00088 #endif // MOD_BASE_PARTSYS_HH
00089 #endif // COMPILING_MODULE
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:12 2007