diff options
-rw-r--r-- | src/crepe/Particle.cpp | 4 | ||||
-rw-r--r-- | src/crepe/Particle.h | 4 | ||||
-rw-r--r-- | src/crepe/api/ParticleEmitter.cpp | 7 | ||||
-rw-r--r-- | src/crepe/api/ParticleEmitter.h | 9 | ||||
-rw-r--r-- | src/crepe/system/ParticleSystem.h | 37 |
5 files changed, 34 insertions, 27 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp index 1c3c138..582edf4 100644 --- a/src/crepe/Particle.cpp +++ b/src/crepe/Particle.cpp @@ -2,8 +2,8 @@ using namespace crepe; -void Particle::reset(uint32_t lifespan, const Vector2& position,const Vector2& velocity, - double angle) { +void Particle::reset(uint32_t lifespan, const Vector2 & position, + const Vector2 & velocity, double angle) { // Initialize the particle state this->time_in_life = 0; this->lifespan = lifespan; diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h index 8782382..3eaebc3 100644 --- a/src/crepe/Particle.h +++ b/src/crepe/Particle.h @@ -43,8 +43,8 @@ public: * \param velocity The initial velocity of the particle. * \param angle The angle of the particle's trajectory or orientation. */ - void reset(uint32_t lifespan, const Vector2& position,const Vector2& velocity, - double angle); + void reset(uint32_t lifespan, const Vector2 & position, + const Vector2 & velocity, double angle); /** * \brief Updates the particle's state. * diff --git a/src/crepe/api/ParticleEmitter.cpp b/src/crepe/api/ParticleEmitter.cpp index 7032f9e..35f960d 100644 --- a/src/crepe/api/ParticleEmitter.cpp +++ b/src/crepe/api/ParticleEmitter.cpp @@ -1,10 +1,11 @@ #include "ParticleEmitter.h" -#include "Particle.h" using namespace crepe; -ParticleEmitter::ParticleEmitter(game_object_id_t game_object_id, const Data & data) - : Component(game_object_id), data(data) { +ParticleEmitter::ParticleEmitter(game_object_id_t game_object_id, + const Data & data) + : Component(game_object_id), + data(data) { for (size_t i = 0; i < this->data.max_particles; i++) { this->data.particles.emplace_back(); } diff --git a/src/crepe/api/ParticleEmitter.h b/src/crepe/api/ParticleEmitter.h index 6e29e60..a9e872f 100644 --- a/src/crepe/api/ParticleEmitter.h +++ b/src/crepe/api/ParticleEmitter.h @@ -1,24 +1,21 @@ #pragma once -#include <cstdint> #include <vector> #include "Component.h" #include "Particle.h" -#include "Sprite.h" #include "Vector2.h" -// class Sprite; - namespace crepe { +class Sprite; + /** * \brief Data holder for particle emission parameters. * * The ParticleEmitter class stores configuration data for particle properties, * defining the characteristics and boundaries of particle emissions. */ - class ParticleEmitter : public Component { public: /** @@ -75,8 +72,6 @@ public: public: /** - * \brief Constructs a ParticleEmitter data holder with specified settings. - * * \param game_object_id Identifier for the game object using this emitter. * \param data Configuration data defining particle properties. */ diff --git a/src/crepe/system/ParticleSystem.h b/src/crepe/system/ParticleSystem.h index 1cde110..0acc2b9 100644 --- a/src/crepe/system/ParticleSystem.h +++ b/src/crepe/system/ParticleSystem.h @@ -12,27 +12,32 @@ class ParticleEmitter; class Transform; /** - * \brief ParticleSystem class responsible for managing particle emission, updates, and bounds checking. + * \brief ParticleSystem class responsible for managing particle emission, + * updates, and bounds checking. */ -class ParticleSystem : public System{ +class ParticleSystem : public System { public: using System::System; /** - * \brief Updates all particle emitters by emitting particles, updating particle states, and checking bounds. + * \brief Updates all particle emitters by emitting particles, updating + * particle states, and checking bounds. */ void update() override; private: /** - * \brief Emits a particle from the specified emitter based on its emission properties. + * \brief Emits a particle from the specified emitter based on its emission + * properties. * * \param emitter Reference to the ParticleEmitter. - * \param transform Const reference to the Transform component associated with the emitter. + * \param transform Const reference to the Transform component associated + * with the emitter. */ void emit_particle(ParticleEmitter & emitter, const Transform & transform); /** - * \brief Calculates the number of times particles should be emitted based on emission rate and update count. + * \brief Calculates the number of times particles should be emitted based on + * emission rate and update count. * * \param count Current update count. * \param emission Emission rate. @@ -41,15 +46,18 @@ private: int calculate_update(int count, double emission) const; /** - * \brief Checks whether particles are within the emitter’s boundary, resets or stops particles if they exit. + * \brief Checks whether particles are within the emitter’s boundary, resets + * or stops particles if they exit. * * \param emitter Reference to the ParticleEmitter. - * \param transform Const reference to the Transform component associated with the emitter. + * \param transform Const reference to the Transform component associated + * with the emitter. */ void check_bounds(ParticleEmitter & emitter, const Transform & transform); /** - * \brief Generates a random angle for particle emission within the specified range. + * \brief Generates a random angle for particle emission within the specified + * range. * * \param min_angle Minimum emission angle in degrees. * \param max_angle Maximum emission angle in degrees. @@ -58,7 +66,8 @@ private: double generate_random_angle(double min_angle, double max_angle) const; /** - * \brief Generates a random speed for particle emission within the specified range. + * \brief Generates a random speed for particle emission within the specified + * range. * * \param min_speed Minimum emission speed. * \param max_speed Maximum emission speed. @@ -67,9 +76,11 @@ private: double generate_random_speed(double min_speed, double max_speed) const; private: - //! Counter to count updates to determine how many times emit_particle is called. - uint32_t update_count = 0; - //! Determines the lowest amount of emission rate (1000 = 0.001 = 1 particle per 1000 updates). + //! Counter to count updates to determine how many times emit_particle is + // called. + unsigned int update_count = 0; + //! Determines the lowest amount of emission rate (1000 = 0.001 = 1 particle + // per 1000 updates). static constexpr unsigned int MAX_UPDATE_COUNT = 100; }; |