aboutsummaryrefslogtreecommitdiff
path: root/src/test/ParticleTest.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-18 15:34:22 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-18 15:34:22 +0100
commitb92da3c729c8fc7c002cb3acbb75c56cb63bd89e (patch)
tree454b64d31b7e0c9151da88a0d49ee782565f49e9 /src/test/ParticleTest.cpp
parent8b449e764b5c91cd3cb0c4fa404a290ab295a7ef (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/events
Diffstat (limited to 'src/test/ParticleTest.cpp')
-rw-r--r--src/test/ParticleTest.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 72f903b..4e655a9 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -16,15 +16,16 @@ using namespace std::chrono_literals;
using namespace crepe;
class ParticlesTest : public ::testing::Test {
-protected:
- ParticleSystem particle_system;
+public:
+ ComponentManager component_manager;
+ ParticleSystem particle_system{component_manager};
+
void SetUp() override {
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
std::vector<std::reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
-
- GameObject game_object(0, "", "", Vector2{0, 0}, 0, 0);
+ GameObject game_object = mgr.new_object("", "", Vector2{0, 0}, 0, 0);
Color color(0, 0, 0, 0);
Sprite test_sprite = game_object.add_component<Sprite>(
@@ -77,7 +78,7 @@ protected:
TEST_F(ParticlesTest, spawnParticle) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
ParticleEmitter & emitter = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
emitter.data.end_lifespan = 5;
emitter.data.boundary.height = 100;
@@ -121,7 +122,7 @@ TEST_F(ParticlesTest, spawnParticle) {
TEST_F(ParticlesTest, moveParticleHorizontal) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
ParticleEmitter & emitter = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
emitter.data.end_lifespan = 100;
emitter.data.boundary.height = 100;
@@ -138,7 +139,7 @@ TEST_F(ParticlesTest, moveParticleHorizontal) {
TEST_F(ParticlesTest, moveParticleVertical) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
ParticleEmitter & emitter = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
emitter.data.end_lifespan = 100;
emitter.data.boundary.height = 100;
@@ -156,7 +157,7 @@ TEST_F(ParticlesTest, moveParticleVertical) {
TEST_F(ParticlesTest, boundaryParticleReset) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
ParticleEmitter & emitter = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
emitter.data.end_lifespan = 100;
emitter.data.boundary.height = 10;
@@ -175,7 +176,7 @@ TEST_F(ParticlesTest, boundaryParticleReset) {
TEST_F(ParticlesTest, boundaryParticleStop) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
+ ComponentManager & mgr = this->component_manager;
ParticleEmitter & emitter = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
emitter.data.end_lifespan = 100;
emitter.data.boundary.height = 10;