Welcome to the seventh part of the 2d particles engine today we will be adding in some more variation to the engine. Also we will be making it run slightly smoother through something I should of realized a long time ago but didn't because I had an idea with it that I probably will not be adding. So lets get to it, first thing were going to do is add and remove some variables from our particles class. We removed the texture variable while adding scale, Acceleration and Origin. Instead of each particle having its own texture because there all the same were just going to use one from the particle engine class. Acceleration and origin will be the same for every particle and for every instance so were going to declare them within the particle engine class when we initialize our particles. You could have also set them in the constructor but there might be more variables like this later so this is fine for now.
Wednesday, May 12, 2010
Saturday, May 8, 2010
Welcome to the sixth part of the particle engine tutorial today we will be optimizing our code to run faster. If you have been following along you will remember the graph in the last tutorial were our particles took up 54% of the memory after only a minute. After the adjustments we will compare our new graph with our old graph. First thing we have to do is get rid of that nasty list in our particle engine and replace it will an array and queue.Now the goal of using an array and queue is to take a particle from our free particles queue and enable it within our array. This is going to change how we create our particles so lets change that first. The particles constructor will no longer set all the properties instead we will create a new method named Initialize to do that.
Wednesday, May 5, 2010
After some time I have finally put together part 5 of the particles tutorial. The reason I wasn't sure of what to do for part 5 will be more clear later on. In this tutorial we will be adding more options to our particle engine, as of right now everything is predefined and pretty boring. Well lets change that now. First were going to change our const speed, rotation speed and life time to a minimum and maximum range. We are also going to add in a minimum and maximum angle.
Sunday, May 2, 2010
Now I am not much of a comment user but there are some times when comments are very helpful and since I am going to start adding comments in my tutorials I thought I would briefly explain how to use them before hand.
One reason I use comments is to signify that something will be changing. The reason I do this is so that in case I forget to change it when I look back on the code I can remember. Now this isn't the best way to use comments as it doesn't really help the readability of your code or your coding efficiency.
The next reason I comment stuff is for things that I may find confusing if I were to look at it in a month. Things such as variables that are sort of complicated, code blocks with a lot of math or random things that look like they don't belong. Other things may include brief explanations for the designer who will be changing that specific variable or group of variables.
Saturday, May 1, 2010
So short tutorial today that will cover adding in our current particle engine to a simple game. Jumping right into it all we need to declare in game1 will be a position vector and our engine.The following code is optional and will remove the 60 frame rate limitation which shows that the engine doesn't rely on the default frame rate, I also changed the screen resolution so that it had more room to show the particles.