void Game::AddToParticleEmitter(int x, int y, PARTICLE_TYPE type, int numParticles) { // create the particle object Particle* pParticle; // create the sprite object Sprite* pParticleSprite = new Sprite(); // setup the particle switch (type) { case ALIEN_EXPLOSION: pParticleSprite = m_pBackBuffer->CreateSprite("assets\\alienfragment.png"); pParticle = new AlienExplosionParticle(); pParticle->Initialise(pParticleSprite, x, y, false); // add to the emitter m_pEmitter->AddParticle(pParticle, numParticles); break; case BULLET_TRAIL: pParticleSprite = m_pBackBuffer->CreateSprite("assets\\playerbullettrail.png"); pParticle = new PlayerBulletTrailParticle(); pParticle->Initialise(pParticleSprite, x, y, false); // add to the emitter m_pEmitter->AddParticle(pParticle, numParticles); break; case STAR_FIELD_SMALL: pParticleSprite = m_pBackBuffer->CreateSprite("assets\\smallstar.png"); break; case STAR_FIELD_BIG: pParticleSprite = m_pBackBuffer->CreateSprite("assets\\biggerstar.png"); break; } }
// Add another particle void FireParticleEmitter::AddParticle() { ColourSequence colourSeq; colourSeq.RedToYellowFast(10); Particle particle; MVector3f p = m_start + (float) m_particles.size() * m_direction; particle.Initialise(p, m_width, m_height, colourSeq); m_particles.push_back(particle); }
// *** CreateParticle void ParticleSystem::CreateParticle(Vector3 const &_pos, Vector3 const &_vel, int _typeId, float _size, RGBAColour col) { if( g_app->GamePaused() ) return; Particle *aParticle = m_particles.GetPointer(); aParticle->Initialise(_pos, _vel, _typeId, _size); if( col != NULL) { aParticle->m_colour = col; } }