diff options
author | jaroWMR <jarorutjes07@gmail.com> | 2024-10-20 12:59:18 +0200 |
---|---|---|
committer | jaroWMR <jarorutjes07@gmail.com> | 2024-10-20 12:59:18 +0200 |
commit | 0f03cdbf23f57116b7664a7c98c4605fd69bb961 (patch) | |
tree | 6e592bd7e94cd5954a8a49209de815fc0ae0becd /src/crepe | |
parent | 016070d47f2fff8cfdd49cc0bdf65c14ef922c94 (diff) |
updated particle system
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/ParticleSystem.cpp | 7 | ||||
-rw-r--r-- | src/crepe/ParticleSystem.h | 2 | ||||
-rw-r--r-- | src/crepe/Transform.cpp | 6 | ||||
-rw-r--r-- | src/crepe/Transform.h | 16 |
4 files changed, 27 insertions, 4 deletions
diff --git a/src/crepe/ParticleSystem.cpp b/src/crepe/ParticleSystem.cpp index 3a1f653..0dad4cd 100644 --- a/src/crepe/ParticleSystem.cpp +++ b/src/crepe/ParticleSystem.cpp @@ -1,8 +1,6 @@ #include "ParticleSystem.h" #include <cmath> -// #include <cstdlib> #include <ctime> -#include <iostream> // include iostream for std::cout #include "ParticleEmitter.h" #include "Particle.h" #include "ComponentManager.h" @@ -11,7 +9,10 @@ using namespace crepe; ParticleSystem::ParticleSystem() : m_elapsedTime(0.0f) {} // Initialize m_elapsedTime to 0 -void ParticleSystem::update(float deltaTime, std::vector<std::reference_wrapper<ParticleEmitter>>& emitters) { +void ParticleSystem::update() { + ComponentManager& mgr = ComponentManager::get_instance(); + std::vector<std::reference_wrapper<ParticleEmitter>> emitters = mgr.get_components_by_type<ParticleEmitter>(); + float deltaTime = 0.10; for (ParticleEmitter& emitter : emitters) { float updateAmount = 1/static_cast<float>(emitter.m_emissionRate); for (float i = 0; i < deltaTime; i += updateAmount) diff --git a/src/crepe/ParticleSystem.h b/src/crepe/ParticleSystem.h index 7b14f71..c8777f5 100644 --- a/src/crepe/ParticleSystem.h +++ b/src/crepe/ParticleSystem.h @@ -9,7 +9,7 @@ namespace crepe { class ParticleSystem { public: ParticleSystem(); - void update(float deltaTime, std::vector<std::reference_wrapper<ParticleEmitter>>& emitters); + void update(); private: void emitParticle(ParticleEmitter &emitter); //emits a new particle diff --git a/src/crepe/Transform.cpp b/src/crepe/Transform.cpp new file mode 100644 index 0000000..0e4b0cf --- /dev/null +++ b/src/crepe/Transform.cpp @@ -0,0 +1,6 @@ +#include "Transform.h" + +using namespace crepe; + +Transform::Transform(int mass, int gravityScale, int bodyType) + : mass(mass), gravity_scale(gravityScale), body_type(bodyType) {} diff --git a/src/crepe/Transform.h b/src/crepe/Transform.h new file mode 100644 index 0000000..c72ebc4 --- /dev/null +++ b/src/crepe/Transform.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Component.h" + +namespace crepe { + +class Transform : public Component { +public: + Transform(int mass, int gravityScale, int bodyType); + + int mass; + int gravity_scale; + int body_type; +}; + +} // namespace crepe |