diff options
-rw-r--r-- | src/crepe/Particle.cpp | 2 | ||||
-rw-r--r-- | src/crepe/Particle.h | 5 | ||||
-rw-r--r-- | src/crepe/api/ParticleEmitter.cpp | 9 | ||||
-rw-r--r-- | src/crepe/api/ParticleEmitter.h | 5 | ||||
-rw-r--r-- | src/crepe/system/ParticleSystem.h | 8 | ||||
-rw-r--r-- | src/crepe/system/PhysicsSystem.h | 10 |
6 files changed, 15 insertions, 24 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp index ab55f37..1c3c138 100644 --- a/src/crepe/Particle.cpp +++ b/src/crepe/Particle.cpp @@ -2,7 +2,7 @@ using namespace crepe; -void Particle::reset(uint32_t lifespan, Vector2 position, Vector2 velocity, +void Particle::reset(uint32_t lifespan, const Vector2& position,const Vector2& velocity, double angle) { // Initialize the particle state this->time_in_life = 0; diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h index 06431bb..8782382 100644 --- a/src/crepe/Particle.h +++ b/src/crepe/Particle.h @@ -30,9 +30,8 @@ public: //! The time the particle has been alive, in milliseconds. uint32_t time_in_life = 0; //! The angle at which the particle is oriented or moving. - double angle; + double angle = 0; - Particle() = default; /** * \brief Resets the particle with new properties. * @@ -44,7 +43,7 @@ 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, Vector2 position, Vector2 velocity, + 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 e7f298c..7032f9e 100644 --- a/src/crepe/api/ParticleEmitter.cpp +++ b/src/crepe/api/ParticleEmitter.cpp @@ -3,16 +3,9 @@ using namespace crepe; -ParticleEmitter::ParticleEmitter(uint32_t game_object_id, const 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(); } } - -ParticleEmitter::~ParticleEmitter() { - std::vector<Particle>::iterator it = this->data.particles.begin(); - while (it != this->data.particles.end()) { - it = this->data.particles.erase(it); - } -} diff --git a/src/crepe/api/ParticleEmitter.h b/src/crepe/api/ParticleEmitter.h index 83a1588..6e29e60 100644 --- a/src/crepe/api/ParticleEmitter.h +++ b/src/crepe/api/ParticleEmitter.h @@ -48,7 +48,7 @@ public: //! position of the emitter Vector2 position; //! maximum number of particles - const uint32_t max_particles = 0; + const unsigned int max_particles = 0; //! rate of particle emission per update (Lowest value = 0.001 any lower is ignored) double emission_rate = 0; //! min speed of the particles @@ -80,8 +80,7 @@ public: * \param game_object_id Identifier for the game object using this emitter. * \param data Configuration data defining particle properties. */ - ParticleEmitter(uint32_t game_object_id, const Data & data); - ~ParticleEmitter(); + ParticleEmitter(game_object_id_t game_object_id, const Data & data); public: //! Configuration data for particle emission settings. diff --git a/src/crepe/system/ParticleSystem.h b/src/crepe/system/ParticleSystem.h index 3155df1..3a118fb 100644 --- a/src/crepe/system/ParticleSystem.h +++ b/src/crepe/system/ParticleSystem.h @@ -2,13 +2,15 @@ #include <cstdint> +#include "System.h" + namespace crepe { class ParticleEmitter; class Transform; /** * \brief ParticleSystem class responsible for managing particle emission, updates, and bounds checking. */ -class ParticleSystem { +class ParticleSystem : public System{ public: /** * \brief Default constructor. @@ -18,7 +20,7 @@ public: /** * \brief Updates all particle emitters by emitting particles, updating particle states, and checking bounds. */ - void update(); + void update() override; private: /** @@ -68,7 +70,7 @@ 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). - static constexpr uint32_t MAX_UPDATE_COUNT = 100; + static constexpr unsigned int MAX_UPDATE_COUNT = 100; }; } // namespace crepe diff --git a/src/crepe/system/PhysicsSystem.h b/src/crepe/system/PhysicsSystem.h index cc13b70..038c120 100644 --- a/src/crepe/system/PhysicsSystem.h +++ b/src/crepe/system/PhysicsSystem.h @@ -1,5 +1,7 @@ #pragma once +#include "System.h" + namespace crepe { /** * \brief System that controls all physics @@ -7,18 +9,14 @@ namespace crepe { * This class is a physics system that uses a rigidbody and transform * to add physics to a game object. */ -class PhysicsSystem { +class PhysicsSystem : public System { public: /** - * Constructor is default - */ - PhysicsSystem() = default; - /** * \brief updates the physics system. * * It calculates new velocties and changes the postion in the transform. */ - void update(); + void update() override; }; } // namespace crepe |