|
This week I have picked up some work that I find very interesting. An enemy spawner! It is going to spawn the enemies in waves that last for 1 minute and we’re going to have 10 waves that we will have to be able to balance. It will be fun to make this enemy spawner! It’s still in research stadium though (or slightly beyond it since I’ve got it figured out…) but since it’s not in our code yet this weeks post will be about our particle engine! Yayyy.
 The particle effects were tricky. I thought I had it all figured out when suddenly someone told me: You have to use vertices! I had no idea what a vertex was so I began researching.
After figuring out what a vertex was I started working on my particle engine. To begin with I had this plan of making an object called ”particle” that contained a vertex of the point type, a position and a velocity that was supposed to be randomized for every particle upon creation. They would have a duration as well.
When I had made almost all of the code for this kind of a particle engine I talked to Tommi and he thought that it all was a bad idea. He said that instead of doing like this I would use vectors containing different positions and vertices, so that there was no object called particles, and that my particle engine were to draw vertices at the positions in the vector. I said fine! And I rewrote my whole code just like that (in the process I learned the difference between and vectors and dynamically allocated arrays!). After this was completed it didn’t work. After some hours of troubleshooting I had to talk to Tommi and he said that we were missing some file for the vertexarray. BLEH.
SO! I went back to where I started. I didn’t want to have to do with the vertices any more. I kind of mixed my idea with Tommi’s suggestion. I made a struct called ”particle” containing a duration, a position, a velocity and an acceleration. All these numbers were slightly randomizing after creating one of these structs (which a for-loop did, containing a randomized number between like… 100 and 150… that’s how many particles that were created). Then sf::squares were created and drawn at the particles location. Perhaps this takes up more computer power or something, but in our little game I think we can afford that.
Another thing that was taken into account when creating the particles was the angle of which the bullet hit it; so that blood shoots out in your face when using the pistol, blood shoots out from both behind and in front of enemies when using the needle gun, and shock-effects fly all around when using the electric arm cannon.
We can now make all kind of crazy particle effects. Which we will!
My particle effect class was named ”EyeCandy” and it also contains pictures such as corpses that are only supposed to be shown during a short time. I made them in a similar way to the particle engine but with sprites. I drew the corpse you see on the picture ^^ it was quick work and I really like the feeling of it.

|