Box2D Cannon Game with Stars
Chapter 8 of Ian Parberry's "Introduction to Game Physics with Box2D"
|
The particle manager. More...
#include <ParticleEngine.h>
Public Member Functions | |
CParticleEngine (int size) | |
Constructor. | |
CParticle * | create (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. | |
CGameObject * | create (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. | |
The particle manager.
The particle engine is responsible for managing particles.
CParticle * CParticleEngine::create | ( | GameObjectType | t, |
int | lifespan | ||
) |
Create a particle given its type and lifespan.
t | Object type. |
lifespan | Lifespan 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.