The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LParticleEngine< PARTICLE, PARTICLEDESC, VECTOR > Class Template Reference

An abstract particle engine. More...

#include <ParticleEngine.h>

Inheritance diagram for LParticleEngine< PARTICLE, PARTICLEDESC, VECTOR >:
LComponent

Public Member Functions

 LParticleEngine ()
 Constructor.
 
virtual ~LParticleEngine ()
 Destructor. More...
 
void create (const PARTICLEDESC &d)
 Create particle. More...
 
void step ()
 Animation step. More...
 
void clear (float=0.1f)
 Fade out all particles. More...
 
void clear (UINT)
 Clear out a particular kind of particle. More...
 
void translate (const VECTOR &)
 Translate. More...
 

Protected Member Functions

void move ()
 Move all particles. More...
 
float GetLifeFraction (const PARTICLE *)
 Get life fraction. More...
 
void cull ()
 Cull old dead particles. More...
 
void rescale ()
 Compute new particle scales. More...
 
void fade ()
 Compute new particle alpha channel. More...
 

Protected Attributes

std::list< PARTICLE * > m_stdList
 Particle list.
 

Additional Inherited Members

- Static Protected Attributes inherited from LComponent
static LTimerm_pTimer = &cTimer
 Pointer to a timer. More...
 
static LRandomm_pRandom = &cRandom
 Pointer to a PRNG. More...
 
static LKeyboardm_pKeyboard = &cKeyboard
 Pointer to a keyboard handler. More...
 
static LXBoxControllerm_pController = &cController
 Pointer to a XBox controller. More...
 
static LSoundm_pAudio = &cAudio
 Pointer to an audio player. More...
 

Detailed Description

template<class PARTICLE, class PARTICLEDESC, class VECTOR>
class LParticleEngine< PARTICLE, PARTICLEDESC, VECTOR >

A particle engine is responsible for managing a system of particles. Its step function must be called once per animation frame. Templates are used to make this class independent of operating system and renderer implementation.

Template Parameters
PARTICLEPartice class.
PARTICLEDESCParticle descriptor.
VECTORVector.

Constructor & Destructor Documentation

◆ ~LParticleEngine()

template<T0 >
LParticleEngine< T0 >::~LParticleEngine
virtual

Destructor. Deletes all of the particles in the particle list.

Member Function Documentation

◆ clear() [1/2]

template<T0 >
void LParticleEngine< T0 >::clear ( float  t = 0.1f)

Pre-emptively trigger a fade out of all particles.

Parameters
tTime over which to fade out.

◆ clear() [2/2]

template<T0 >
void LParticleEngine< T0 >::clear ( UINT  n)

Pre-emptively trigger scale out of all particles of a given type.

Parameters
nSprite type of particle to be cleared.

◆ create()

template<T0 >
void LParticleEngine< T0 >::create ( const PARTICLEDESC &  d)

Create a particle given its particle descriptor.

Parameters
dParticle descriptor.

◆ cull()

template<T0 >
void LParticleEngine< T0 >::cull
protected

Remove from the particle list and delete those particles that have reached or exceeded their lifespan.

◆ fade()

template<T0 >
void LParticleEngine< T0 >::fade
protected

Fade out all particles in the particle list according to how much of their lifespans they have lived up to this point.

◆ GetLifeFraction()

template<T0 >
float LParticleEngine< T0 >::GetLifeFraction ( const PARTICLE *  p)
protected

Get the remaining fraction of a particle's lifespan.

Parameters
pPointer to a particle.
Returns
Particle's age as a float between 0.0f and 1.0f.

◆ move()

template<T0 >
void LParticleEngine< T0 >::move
protected

Move all particles in the particle list.

◆ rescale()

template<T0 >
void LParticleEngine< T0 >::rescale
protected

Rescale all of the particles in the particle list according to how much of their lifespans they have lived up to this point.

◆ step()

template<T0 >
void LParticleEngine< T0 >::step

Move all particles, cull any that have exceeded their lifespan, and recompute the scale and transparency of the ones remaining.

◆ translate()

template<T0 >
void LParticleEngine< T0 >::translate ( const VECTOR &  delta)

Translate all particles simultaneously by the same amount.

Parameters
deltaTranslation amount.