[5SD033]Blog 5 – Particle Generator
By: Martin Carlsson Group: 10 One of the artifacts I have been working on this week is our particle generator. The reason we wanted a particle generator is mainly to improve the player feedback in the game. First of, the particle generator serves as a indicator for the air level. When the air level is high, the particles are smaller. When the air level is low, the particles are much larger. The hope is that this will be enough of an indicator along with our hud elements and screen flash to make sure the player notices what is going on. ![]() Secondly, the particles give the player feedback after defeating enemies and points out power ups. Such as the bubble trail from the bubble power up, or the blood effect from killing the swordfish. This gives the player a bit more feedback and enforces our more realistic theme, rather than only having a dead fish floating upside down. ![]() The design of the particle system is very basic. It essentially includes an emitter, a generator and a std::vector of particles. The emitter tells the generator to create new particles. The emitter has a max particle amount variable and will tell the generator to create new particles until the max has been met. To create the particles, the generator takes: Size, position and color. The speed, direction angle and lifetime of the particles are randomly determined by the generator. The particles themselves are objects of the class Particles. The class Particles is sf::Drawable and contains a sprite and the variables from the generator. The particles get stored in a std::vector in the particle handler. The particle handler does what it’s named. It handles everything about the particles.It contains the emitter, the generator and it updates the particles. When a particle has completed its lifetime, it gets removed and another particle is available to be generated. The game state then draws the particles and voila, we have particles. The way this is implemented is certainly not optimized or advanced, but it serves the needs of our project. Thank you for reading!
|

