diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-22 13:48:46 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-22 13:48:46 +0100 |
commit | 6a7e06f875d789af0e8f9b5ce0ad24b9eaa96d25 (patch) | |
tree | 07397ab46e2518fde4140777e2e181cde8ad938e /src/crepe/system/ParticleSystem.cpp | |
parent | 296c80edd6727d6808ed0c98c001a8b456f1c037 (diff) | |
parent | 61148c757a1f742ff09e40e5347e74e638c7371c (diff) |
Merge branch 'master' into niels/UI
Diffstat (limited to 'src/crepe/system/ParticleSystem.cpp')
-rw-r--r-- | src/crepe/system/ParticleSystem.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/crepe/system/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp index 5e575e4..f026390 100644 --- a/src/crepe/system/ParticleSystem.cpp +++ b/src/crepe/system/ParticleSystem.cpp @@ -50,9 +50,10 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter, const Transform & constexpr float DEG_TO_RAD = M_PI / 180.0; vec2 initial_position = AbsolutePosition::get_position(transform, emitter.data.offset); - float random_angle - = this->generate_random_angle(emitter.data.min_angle + transform.rotation, - emitter.data.max_angle + transform.rotation); + float random_angle = this->generate_random_angle( + emitter.data.min_angle + transform.rotation, + emitter.data.max_angle + transform.rotation + ); float random_speed = this->generate_random_speed(emitter.data.min_speed, emitter.data.max_speed); @@ -63,8 +64,9 @@ void ParticleSystem::emit_particle(ParticleEmitter & emitter, const Transform & for (Particle & particle : emitter.particles) { if (!particle.active) { - particle.reset(emitter.data.end_lifespan, initial_position, velocity, - random_angle); + particle.reset( + emitter.data.end_lifespan, initial_position, velocity, random_angle + ); break; } } @@ -82,8 +84,9 @@ void ParticleSystem::check_bounds(ParticleEmitter & emitter, const Transform & t for (Particle & particle : emitter.particles) { const vec2 & position = particle.position; - bool within_bounds = (position.x >= left && position.x <= right && position.y >= top - && position.y <= bottom); + bool within_bounds + = (position.x >= left && position.x <= right && position.y >= top + && position.y <= bottom); //if not within bounds do a reset or stop velocity if (!within_bounds) { if (emitter.data.boundary.reset_on_exit) { |