From d69adb5666fd6f73edbc6d410afcdf23c24e7c6b Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 8 Nov 2024 19:20:05 +0100 Subject: particle updated --- src/crepe/api/ParticleEmitter.cpp | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'src/crepe/api/ParticleEmitter.cpp') diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp index 3b2e2f2..f585a81 100644 --- a/src/crepe/api/ParticleEmitter.cpp +++ b/src/crepe/api/ParticleEmitter.cpp @@ -1,36 +1,19 @@ -#include -#include - #include "Particle.h" #include "ParticleEmitter.h" using namespace crepe; -ParticleEmitter::ParticleEmitter(game_object_id_t id, uint32_t max_particles, - uint32_t emission_rate, uint32_t speed, - uint32_t speed_offset, uint32_t angle, - uint32_t angleOffset, float begin_lifespan, - float end_lifespan) - : Component(id), max_particles(max_particles), emission_rate(emission_rate), - speed(speed), speed_offset(speed_offset), position{0, 0}, - begin_lifespan(begin_lifespan), end_lifespan(end_lifespan) { - std::srand( - static_cast(std::time(nullptr))); // initialize random seed - std::cout << "Create emitter" << std::endl; - // FIXME: Why do these expressions start with `360 +`, only to be `% 360`'d - // right after? This does not make any sense to me. - min_angle = (360 + angle - (angleOffset % 360)) % 360; - max_angle = (360 + angle + (angleOffset % 360)) % 360; - position.x = 400; // FIXME: what are these magic values? - position.y = 400; - for (size_t i = 0; i < max_particles; i++) { - this->particles.emplace_back(); - } +ParticleEmitter::ParticleEmitter(uint32_t game_object_id, const ParticleEmitterData& data) : Component(game_object_id),data(data) { + for (size_t i = 0; i < this->data.max_particles; i++) { + this->data.particles.emplace_back(); + } } + ParticleEmitter::~ParticleEmitter() { - std::vector::iterator it = this->particles.begin(); - while (it != this->particles.end()) { - it = this->particles.erase(it); + std::vector::iterator it = this->data.particles.begin(); + while (it != this->data.particles.end()) { + it = this->data.particles.erase(it); } } + -- cgit v1.2.3