Box2D Cannon Game with Stars
Chapter 8 of Ian Parberry's "Introduction to Game Physics with Box2D"
 All Classes Files Functions Variables Enumerations Friends Pages
Public Member Functions | List of all members
CParticleEngine Class Reference

The particle manager. More...

#include <ParticleEngine.h>

Inheritance diagram for CParticleEngine:
CObjectManager

Public Member Functions

 CParticleEngine (int size)
 Constructor.
 
CParticlecreate (GameObjectType t, int lifespan)
 
void move ()
 Move all particles.
 
void draw ()
 Draw all particles.
 
- Public Member Functions inherited from CObjectManager
 CObjectManager (int size)
 Constructor.
 
 ~CObjectManager ()
 Destructor.
 
CGameObjectcreate (GameObjectType objecttype)
 Create new object.
 
void move ()
 Move all objects.
 
void draw ()
 Draw all objects.
 
void clear ()
 Clear the object list.
 

Additional Inherited Members

- Protected Attributes inherited from CObjectManager
CGameObject ** m_pObjectList
 List of game objects.
 
int m_nCount
 How many objects in list.
 
int m_nSize
 Maximum size of list.
 

Detailed Description

The particle manager.

The particle engine is responsible for managing particles.

Member Function Documentation

CParticle * CParticleEngine::create ( GameObjectType  t,
int  lifespan 
)

Create a particle given its type and lifespan.

Parameters
tObject type.
lifespanLifespan in ms.
void CParticleEngine::draw ( )

Draw all particles.

Draw all particles. The particles grow from nothing and rotate in one direction until half their lifespan has passed, then they shrink and rotate the other way until they disappear entirely. At that point the move() function is supposed to cull them. If it fails to cull them, you'll see particles getting very, very big.

void CParticleEngine::move ( )

Move all particles.

Move particles, and cull them if they've exceeded their lifespan. Moving them in fact means rotating them, since they don't actually change their locations.