/////////////////////////////////////////////////////////////////////// // CEmitter.h // Author: Christian Benavides // Description: Class in charge of managing the initialization and // update of the particles. //////////////////////////////////////////////////////////////////////// #pragma once #include #define MAX_NUM_PARTICLES 100 #define DEFAULT_SPEED 10 class CParticle; class CConsole; class CPlane; class CEmitter { Vector m_ptPosition; std::vector m_vAliveParticles; std::vector m_vDeadParticles; std::vector::iterator m_itAliveIterator; float m_fSpawnRatePerSec; float m_fSpawnTimer; float m_fMaxLifeTime; int m_nNumParticles; CPlane* m_myGroundPlane; /// Plane to test against public: CEmitter(); CEmitter(Vector _ptPosition, const int& _nNumParticles, const float& _fLifeTime , const float& _fSpawnRate); ~CEmitter(); /*ACCESORS*/ Vector GetPosition() const { return m_ptPosition; }; int GetNumParticles() const { return m_nNumParticles; }; float GetSpawnRate() const { return m_fSpawnRatePerSec; }; float GetLifeTime() const { return m_fMaxLifeTime; }; /*MUTATORS*/ void SetPosition(Vector _ptPosition) { m_ptPosition= _ptPosition; }; void SetNumParticles(int _nNumParticles) { m_nNumParticles = _nNumParticles; }; void SetSpawnRate(float _fSpawnRate) { m_fSpawnRatePerSec= _fSpawnRate; }; void SetLifeTime(float _fLifeTime) { m_fMaxLifeTime = _fLifeTime; }; void SetPlane(CPlane* _pPlane) { m_myGroundPlane = _pPlane; }; /*METHODS*/ CParticle* InitializeParticle(); void RemoveParticle(std::vector::iterator& _pParticle); float GetRandomLifeTime() const; Vector GetRandomVelocity() const; void Update(float _dt); void PrintParticleStatus(CConsole* _hConsole); void TestAgainstPlane(CParticle** _plane); };