So with that in mind, what we will do is separate the information that will be shared by each particle, which we will call a ParticleSystem:
// Abstract class for us to derive from
class ParticleSystem
{
public:
float lifeTime;
M5Vec2 startScale;
float endScale;
// Pure virtual functions
virtual void Init(M5Object * object) = 0;
virtual void Update(M5Object * object, float dt, float lifeLeft) = 0;
float Lerp(float start, float end, float fraction);
};
The class acts as our intrinsic state, which is shared. Since the starting scale, end scale, and lifetime of our object never change, it makes sense for these variables to be shared instead of each object having one. In our previous example, we only had one particle system, but we may want the ability to have more as well, and it's when we start using it that some of the benefits of the Flyweight pattern become...