Using the ParticleFactory

Next, we will need to adjust our previously created Particle archetype and component to reflect these changes.

First, we want to change our .ini file. Since the Particle object is meant for all particle types, instead of having the properties being set there, we will instead set a base type for us to use:

posX   = 0 posY   = 0 velX   = 0 velY   = 0 scaleX = 2.5 scaleY = 2.5 rot    = 0 rotVel = 0 components =  GfxComponent ParticleComponent  [GfxComponent] texture = particle.tga drawSpace = world  [ParticleComponent] type = Moving 

This simplifies the particle object itself, but it's for a good cause. We will now update the code of the ParticleComponent class as follows:

 /******************************************************************************/ ...

Get Game Development Patterns and Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.