aboutsummaryrefslogtreecommitdiff
path: root/src/test/ParticleTest.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
commitfee42c67918a9370f7f4e074dba9a677afccf90b (patch)
treec5ed200e3c584fafc4c6bd3df48adeed3cfbd31d /src/test/ParticleTest.cpp
parented1403aea4412bd479244eae8e2940190e71cd28 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/RenderingParticle
Diffstat (limited to 'src/test/ParticleTest.cpp')
-rw-r--r--src/test/ParticleTest.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 6fe3133..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,9 +78,8 @@ protected:
TEST_F(ParticlesTest, spawnParticle) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
- ParticleEmitter & emitter
- = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
+ 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;
emitter.data.boundary.width = 100;
@@ -122,9 +122,8 @@ TEST_F(ParticlesTest, spawnParticle) {
TEST_F(ParticlesTest, moveParticleHorizontal) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
- ParticleEmitter & emitter
- = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
+ 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;
emitter.data.boundary.width = 100;
@@ -140,9 +139,8 @@ TEST_F(ParticlesTest, moveParticleHorizontal) {
TEST_F(ParticlesTest, moveParticleVertical) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
- ParticleEmitter & emitter
- = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
+ 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;
emitter.data.boundary.width = 100;
@@ -159,9 +157,8 @@ TEST_F(ParticlesTest, moveParticleVertical) {
TEST_F(ParticlesTest, boundaryParticleReset) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
- ParticleEmitter & emitter
- = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
+ 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;
emitter.data.boundary.width = 10;
@@ -179,9 +176,8 @@ TEST_F(ParticlesTest, boundaryParticleReset) {
TEST_F(ParticlesTest, boundaryParticleStop) {
Config::get_instance().physics.gravity = 1;
- ComponentManager & mgr = ComponentManager::get_instance();
- ParticleEmitter & emitter
- = mgr.get_components_by_id<ParticleEmitter>(0).front().get();
+ 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;
emitter.data.boundary.width = 10;