home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / xenon / includes / particleeffect.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-03  |  1.8 KB  |  92 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CParticleEffect
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CActor
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_PARTICLEEFFECT_H
  16. #define _INCLUDE_PARTICLEEFFECT_H
  17.  
  18. #include "actor.h"
  19.  
  20. //-------------------------------------------------------------
  21.  
  22. const float INFINITE_LIFETIME = 99999.f;
  23.  
  24. //-------------------------------------------------------------
  25. // Simple particle
  26.  
  27. struct Particle
  28. {
  29.     gsCVector m_position;
  30.     gsCVector m_velocity;
  31.     float m_mass;
  32.     float m_age;
  33.     float m_lifetime;
  34. };
  35.  
  36. //-------------------------------------------------------------
  37.  
  38. class CParticleEffect : public CActor
  39. {
  40.     private:
  41.  
  42.         gsCVector m_offset;
  43.  
  44.         gsCList<Particle *> m_particle_list;
  45.  
  46.         bool m_point_force;
  47.  
  48.         gsCVector m_force_position;
  49.         gsCVector m_force_direction;        // ignored if point force
  50.         float m_force_strength;                // ignored if directional force
  51.  
  52.         gsCTimer m_life_timer;
  53.         float m_lifetime;
  54.  
  55.         void destroy();
  56.  
  57.     public:
  58.         CParticleEffect();
  59.         virtual ~CParticleEffect();
  60.  
  61.         virtual bool activate();
  62.         void kill();
  63.  
  64.         void onLeavingScreen();
  65.  
  66.         virtual Particle *createParticle() = 0;
  67.  
  68.         bool update(Controls *controls);
  69.         bool draw();
  70.  
  71.         void setOffset(const gsCVector offset);
  72.         void setLifetime(float time);
  73. };
  74.  
  75. //-------------------------------------------------------------
  76.  
  77. inline void CParticleEffect::setOffset(const gsCVector offset)
  78. {
  79.     m_offset = offset;
  80. }
  81.  
  82. //-------------------------------------------------------------
  83.  
  84. inline  void CParticleEffect::setLifetime(float time)
  85. {
  86.     m_lifetime = time;
  87. }
  88.  
  89. //-------------------------------------------------------------
  90.  
  91. #endif
  92.