diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 1743d6d..242d0bc 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -49,7 +49,7 @@ void GameWorld::Initialize() model->ModelFile = "Models/Placeholders/tank/Chassi.obj"; } - for(int i = 0; i < 83; i++) + for(int i = 0; i < 2; i++) { auto light = CreateEntity(); auto transform = AddComponent(light, "Transform"); @@ -67,7 +67,7 @@ void GameWorld::Initialize() model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj"; } - for(int i = 0; i < 500; i++) + for(int i = 0; i < 3; i++) { auto ball = CreateEntity(); auto transform = AddComponent(ball, "Transform"); @@ -100,7 +100,7 @@ void GameWorld::Initialize() emitter->LifeTime = 4; emitter->SpawnCount = 3; emitter->SpreadAngle = 35; - emitter->SpawnFrequency = 0.3; + emitter->SpawnFrequency = 0.01; //emitter-> } } diff --git a/src/Systems/ParticleSystem.cpp b/src/Systems/ParticleSystem.cpp index 048832d..d2ccc8c 100644 --- a/src/Systems/ParticleSystem.cpp +++ b/src/Systems/ParticleSystem.cpp @@ -25,23 +25,25 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID { if(m_TimeSinceLastSpawn > emitterComponent->SpawnFrequency) { - SpawnParticles(entity, emitterComponent->SpawnCount, emitterComponent->SpreadAngle); - m_TimeSinceLastSpawn = 0; + if(m_ParticleEmitter[entity].size() < 100) + { + SpawnParticles(entity, emitterComponent->SpawnCount, emitterComponent->SpreadAngle); + m_TimeSinceLastSpawn = 0; + } + std::cout<<"Particle count: "<::iterator it; - for(it = m_ParticleEmitter[entity].begin(); it == m_ParticleEmitter[entity].end();) + for(it = m_ParticleEmitter[entity].begin(); it != m_ParticleEmitter[entity].end();) { auto particleComponent = m_World->GetComponent(it->ParticleID, "Particle"); - if(!particleComponent) - break; + double timeLived = glfwGetTime() - it->SpawnTime; - std::cout< particleComponent->LifeTime) { m_ParticleEmitter[entity].erase(it); + std::cout<<"Removed dead particle..."<LifeTime; // The difference between the start and end value float deltaColor = glm::abs(particleComponent->ColorSpectrum[0].r - particleComponent->ColorSpectrum[1].r); @@ -70,7 +72,7 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID deltaVelocity = glm::abs(particleComponent->VelocitySpectrum[0].y - particleComponent->VelocitySpectrum[1].y); it->Velocity.y = particleComponent->VelocitySpectrum[0].y + deltaVelocity * timeProgress; deltaVelocity = glm::abs(particleComponent->VelocitySpectrum[0].z - particleComponent->VelocitySpectrum[1].z); - it->Velocity.z = particleComponent->VelocitySpectrum[0].z + deltaVelocity * timeProgress; + it->Velocity.z = particleComponent->VelocitySpectrum[0].z + deltaVelocity * timeProgress;*/ } } } @@ -83,7 +85,6 @@ void Systems::ParticleSystem::RegisterComponents(ComponentFactory* cf) void Systems::ParticleSystem::SpawnParticles(EntityID emitterID, float spawnCount, float spreadAngle) { - std::list particles; for(int i = 0; i < spawnCount; i++) { auto ent = m_World->CreateEntity(); @@ -92,7 +93,7 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID, float spawnCoun transform->Position = glm::vec3(0); auto particle = m_World->AddComponent(ent, "Particle"); - particle->LifeTime = 4000; + particle->LifeTime = 4; Color startColor = {.4f, .45f, .2f}; particle->ColorSpectrum.push_back(startColor); Color endColor = {0.f, 45.f, 23.f}; @@ -110,6 +111,7 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID, float spawnCoun m_ParticleEmitter[emitterID].push_back(data); } + std::cout<<"Added "< - namespace Systems {