// // Created by SeanOMik on 3/21/2021. // Github: https://github.com/SeanOMik // Email: seanomik@gmail.com // #ifndef SIMPLEENGINE_PARTICLE_EMITTER_H #define SIMPLEENGINE_PARTICLE_EMITTER_H #include "../event.h" #include "particle_property.h" #include "particle.h" #include "../random.h" #include "../range_2.h" #include #include #include #include #include #include namespace simpleengine { namespace particle { struct ParticleAttributes { uint32_t lifetime_ms; sf::Vector2f start_velocity; float rotation_velocity = 0; sf::Vector2f scale = sf::Vector2f(1, 1); }; class ParticleEmitter : public simpleengine::Event { protected: using ParticlePropertyPtr = std::shared_ptr; using ParticlePropertyVector = std::vector; public: ParticleEmitter(sf::Texture& texture, sf::Vector2f position, double emit_variance, uint32_t emit_count, uint32_t particle_count, Range2f particle_range, ParticleAttributes attributes, ParticlePropertyVector& properties); void SetProperties(ParticlePropertyVector& properties); virtual void Update(const float& delta_time) override; virtual void Render(sf::RenderTarget* target) override; protected: sf::Texture& texture; sf::Vector2f position; double emit_variance; uint32_t emit_count; uint32_t particle_count; Range2f particle_range; ParticleAttributes attributes; ParticlePropertyVector& properties; std::vector particles; sf::Clock time; simpleengine::Random random; }; } } #endif //SIMPLEENGINE_PARTICLE_EMITTER_H