hey, I'm designing a particle system in C++ and I need help figuring out HOW im going to go about using the same code for bullets, and explosions to rain and stuff like that,
I have a particle system header like,
#ifndef _Particle_Factory_H
#define _Particle_Factory_H
#include <SFML/Graphics.hpp>
#include <vector>
#include "objects.h"
//Simple Particle system
class Particle_Factory : public Objects
{
public:
//Spawn p_count # of particles at Position pos
void Emit( int p_count, sf::Vector2f vel, sf::Vector2f pos);
//Modify Velocity
void Modify( sf::Vector2f new_velocity);
//Update Particle Mechanics
void Logic_Update();
//Destroy Particle when it is useless
void Destroy_Particle(Objects &p);
//Draw to screen
void Draw();
std::vector <Objects> particles;
};
//static std::vector < Objects > particles;
#endif
Now how would I be able to attach this to an ammo class and use its properties like damage when they collide with player/enemies?
How would i attach this to other classes so like, Bullet class
can use functions from the particle_factory, so it can call,
ammo.emit(100, velocity, position);
and it will create 100 particles at 'position' with direction and speed of 'velocity'. And when it hits the player, does a certain amount 'damage'.
Now how would I turn around and include that same particle_factory class into an explosion class and call,
explosion.emit(100, velocity, position);
so that the 100 particles created have different damage, collision response, and image than those created with the ammo class. Collision Response is the biggest issue, I can hack a solution for the other properties but i just cant' figure out a way to design a system that can use different types of collision response, for different items using the same particle factory system.
I'm looking for how to design this system rather than how to code it.
Any help would be much appreciated, if I was not clear on something please let me know,
Thanks.