Welcome to the third part of the 2d particle engine tutorial. Today we will be adding our basic particle engine class that will hold all of our particles info. Now what we want this class to do is load, create, update and draw our particles as well as creating new ones. Now before we begin let me say that this class is the core of our engine and will be very complex in the end so throughout the tutorial as we add in more stuff I will also be adding in comments to help explain what everything does. There are some special ways to adding in comments that I will explain part way between the tutorial that will help when coding large projects.
So lets begin, first lets create a new class named ParticleEngine and add in the following variables.
Now lets go over the variables we added since some of them might not be obvious. Our random variable is going help us in creating a lot of completely different particles using random numbers. Our list of particles holds our particles and texture is the texture of our particles. Our speed variable is the speed of our particles, amount is how many particles we want to create every second and our time per particle lets us know how long it takes for each particle. This is similar to our sprite animation updating. Lifetime is how long our particles will be alive which we set to 1 second, our speed of rotation for our particles and the blend mode we will be using for our drawing. This is set to alpha blend now but additive is also a good one. The last two keep track of how many particles we have to create this frame and how much time has passed before our next particle is created. More explanation when we go over the updating method.