From 0006e959643f0150acd230b174287a85d4cb3255 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 10 Nov 2024 18:30:10 +0100 Subject: added forward declaration and const reference sprite --- src/test/ParticleTest.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/test/ParticleTest.cpp') diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp index 8c6a7e7..7883eca 100644 --- a/src/test/ParticleTest.cpp +++ b/src/test/ParticleTest.cpp @@ -5,25 +5,36 @@ #include #include #include +#include +#include #include #include - +#include using namespace std; using namespace std::chrono_literals; using namespace crepe; + + class ParticlesTest : public ::testing::Test { protected: - GameObject * game_object; ParticleSystem particle_system; void SetUp() override { ComponentManager & mgr = ComponentManager::get_instance(); std::vector> transforms = mgr.get_components_by_id(0); if (transforms.empty()) { - game_object = new GameObject(0, "", "", Vector2{0, 0}, 0, 0); - game_object->add_component(ParticleEmitter::Data{ + + + GameObject game_object(0, "", "", Vector2{0, 0}, 0, 0); + + Color color(0, 0, 0, 0); + Sprite test_sprite = game_object.add_component( + make_shared("../asset/texture/img.png"), color, + FlipSettings{true, true}); + + game_object.add_component(ParticleEmitter::Data{ .position = {0,0}, .max_particles = 100, .emission_rate = 0, @@ -40,7 +51,7 @@ protected: .offset = Vector2{0,0}, .reset_on_exit = false, }, - .sprite = nullptr, + .sprite = test_sprite, }); } transforms = mgr.get_components_by_id(0); @@ -61,7 +72,6 @@ protected: emitter.data.end_lifespan = 0; emitter.data.force_over_time = Vector2{0, 0}; emitter.data.boundary = {0, 0, Vector2{0, 0}, false}; - emitter.data.sprite = nullptr; for (auto& particle : emitter.data.particles) { particle.active = false; } -- cgit v1.2.3