diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 21:54:28 +0200 |
commit | 9b7be419c9dcc6ebd1e504713c7b2676ca3d2fdf (patch) | |
tree | 97a2fc5ce1ec1345bd6f44889682ea9a2ffafd76 /src/crepe/api/ParticleEmitter.cpp | |
parent | 080ad535e6fc6666b919b1a21b6986aaf9b678eb (diff) |
`clang-format`
Diffstat (limited to 'src/crepe/api/ParticleEmitter.cpp')
-rw-r--r-- | src/crepe/api/ParticleEmitter.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp index 318c6db..298a5ec 100644 --- a/src/crepe/api/ParticleEmitter.cpp +++ b/src/crepe/api/ParticleEmitter.cpp @@ -1,28 +1,36 @@ #include "ParticleEmitter.h" -#include <ctime> #include "Particle.h" +#include <ctime> #include <iostream> using namespace crepe; -ParticleEmitter::ParticleEmitter(uint32_t gameObjectId ,uint32_t maxParticles, uint32_t emissionRate, uint32_t speed, uint32_t speedOffset, uint32_t angle, uint32_t angleOffset, float m_beginLifespan, float m_endLifespan) - : Component(gameObjectId), m_maxParticles(maxParticles), m_emissionRate(emissionRate), m_speed(speed), m_speedOffset(speedOffset), m_position{0, 0}, m_beginLifespan(m_beginLifespan),m_endLifespan(m_endLifespan) { - std::srand(static_cast<uint32_t>(std::time(nullptr))); // initialize random seed - std::cout << "Create emitter" << std::endl; - m_minAngle = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle - m_maxAngle = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle +ParticleEmitter::ParticleEmitter(uint32_t gameObjectId, uint32_t max_particles, + uint32_t emission_rate, uint32_t speed, + uint32_t speed_offset, uint32_t angle, + uint32_t angleOffset, float m_begin_lifespan, + float m_end_lifespan) + : Component(gameObjectId), m_max_particles(max_particles), + m_emission_rate(emission_rate), m_speed(speed), m_speed_offset(speed_offset), + m_position{0, 0}, m_begin_lifespan(m_begin_lifespan), + m_end_lifespan(m_end_lifespan) { + std::srand( + static_cast<uint32_t>(std::time(nullptr))); // initialize random seed + std::cout << "Create emitter" << std::endl; + m_min_angle + = (360 + angle - (angleOffset % 360)) % 360; // calculate minAngle + m_max_angle + = (360 + angle + (angleOffset % 360)) % 360; // calculate maxAngle m_position.x = 400; m_position.y = 400; - for (size_t i = 0; i < m_maxParticles; i++) - { - this->particles.emplace_back(); - } - + for (size_t i = 0; i < m_max_particles; i++) { + this->particles.emplace_back(); + } } ParticleEmitter::~ParticleEmitter() { - std::vector<Particle>::iterator it = this->particles.begin(); - while (it != this->particles.end()) { - it = this->particles.erase(it); - } + std::vector<Particle>::iterator it = this->particles.begin(); + while (it != this->particles.end()) { + it = this->particles.erase(it); + } } |