diff options
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/components_internal.cpp | 4 | ||||
-rw-r--r-- | src/example/particle.cpp | 17 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp index 54ce295..3ba5b5a 100644 --- a/src/example/components_internal.cpp +++ b/src/example/components_internal.cpp @@ -39,8 +39,8 @@ int main() { auto stop_adding = chrono::high_resolution_clock::now(); auto sprites = mgr.get_components_by_type<Sprite>(); - for (auto sprite : sprites) { - assert(sprite.get().path == "test"); + for (auto & sprite : sprites) { + assert(sprite.path == "test"); } auto stop_looping = chrono::high_resolution_clock::now(); diff --git a/src/example/particle.cpp b/src/example/particle.cpp index fc56230..df1dbfd 100644 --- a/src/example/particle.cpp +++ b/src/example/particle.cpp @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) { return 1; } - auto & mgr = ComponentManager::get_instance(); + GameObject * game_object[1]; game_object[0] = new GameObject(0, "Name", "Tag", 0); @@ -32,19 +32,19 @@ int main(int argc, char* argv[]) { ParticleSystem particleSystem; unsigned int maxParticles = 100; // maximum number of particles - unsigned int emissionRate = 1; // particles created per second + unsigned int emissionRate = 10; // particles created per second unsigned int speed = 50; // base speed of particles unsigned int speedOffset = 10; // random offset for particle speed - unsigned int angle = 90; // base angle of particle emission + unsigned int angle = 270; // base angle of particle emission unsigned int angleOffset = 30; // random offset for particle angle float beginLifespan = 0.0f; // beginning lifespan of particles - float endLifespan = 2.0f; // ending lifespan of particles + float endLifespan = 6.0f; // ending lifespan of particles // Vector to hold all the emitters // vector<ParticleEmitter> emitters; game_object[0]->add_component<ParticleEmitter>(maxParticles, emissionRate, speed, speedOffset, angle, angleOffset, beginLifespan, endLifespan); - std::vector<std::reference_wrapper<ParticleEmitter>> emitters = mgr.get_components_by_type<ParticleEmitter>(); + // Loop to create 1000 emitters @@ -65,7 +65,10 @@ int main(int argc, char* argv[]) { // Start timing auto start = chrono::high_resolution_clock::now(); - particleSystem.update(deltaTime, emitters); // update particle system with delta time and emitters + + // POC CODE + particleSystem.update(); + // POC CODE // End timing auto end = chrono::high_resolution_clock::now(); @@ -76,6 +79,8 @@ int main(int argc, char* argv[]) { start = chrono::high_resolution_clock::now(); // render particles using the drawSquare method from SDLApp + ComponentManager& mgr = ComponentManager::get_instance(); + std::vector<std::reference_wrapper<ParticleEmitter>> emitters = mgr.get_components_by_type<ParticleEmitter>(); for (const ParticleEmitter& emitter : emitters) { for (const Particle& particle : emitter.particles) { if(particle.active)app.drawSquare(particle.position.x, particle.position.y, 5); // draw each particle |