April 2017
Beginner to intermediate
394 pages
9h 16m
English
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 ...
Read now
Unlock full access