<commit_before>#include "Particles.hpp"

#include <Util/Easing.hpp>

#include <SFML/Graphics/RenderTarget.hpp>

#include <algorithm>
#include <cassert>
#include <cmath>

namespace
{
	Easers::Cubic sAlphaEaser;
	sf::Texture sParticleTexture;
}

std::list<ParticleManager::Particle> ParticleManager::mParticles;

void ParticleManager::init()
{
	sParticleTexture.loadFromFile("Resources/Particles.png");
}

void ParticleManager::addParticle(Particle&& p)
{
	p.StartLife = p.Life;

	auto it = std::lower_bound(mParticles.begin(), mParticles.end(), p);
	mParticles.insert(it, std::move(p));
}
void ParticleManager::clearParticles()
{
	mParticles.clear();
}
void ParticleManager::variadic_update(float dt)
{
	for (auto it = mParticles.begin(); it != mParticles.end();)
	{
		it->Life -= dt;
		it->Velocity.y = std::min(700.f, it->Velocity.y + 400.f*dt);
		it->Position += it->Velocity * dt;
		it->Angle += it->Rotation * dt;

		it->Color.a = 255 * sAlphaEaser.Out(it->Life / it->StartLife);

		if (it->Life <= 0)
			it = mParticles.erase(it);
		else
			++it;
	}
<commit_msg>Clean up particles if they drop off screen<commit_after>#include "Particles.hpp"

#include <Util/Easing.hpp>

#include <SFML/Graphics/RenderTarget.hpp>

#include <algorithm>
#include <cassert>
#include <cmath>

namespace
{
	Easers::Cubic sAlphaEaser;
	sf::Texture sParticleTexture;
}

std::list<ParticleManager::Particle> ParticleManager::mParticles;

void ParticleManager::init()
{
	sParticleTexture.loadFromFile("Resources/Particles.png");
}

void ParticleManager::addParticle(Particle&& p)
{
	p.StartLife = p.Life;

	auto it = std::lower_bound(mParticles.begin(), mParticles.end(), p);
	mParticles.insert(it, std::move(p));
}
void ParticleManager::clearParticles()
{
	mParticles.clear();
}
void ParticleManager::variadic_update(float dt)
{
	for (auto it = mParticles.begin(); it != mParticles.end();)
	{
		it->Life -= dt;
		it->Velocity.y = std::min(700.f, it->Velocity.y + 400.f*dt);
		it->Position += it->Velocity * dt;
		it->Angle += it->Rotation * dt;

		it->Color.a = 255 * sAlphaEaser.Out(it->Life / it->StartLife);

		if (it->Life <= 0 || it->Position.y > 1000)
			it = mParticles.erase(it);
		else
			++it;
	}

{'fraction_non_alphanumeric': 0.17550274223034734, 'fraction_numerical': 0.010968921389396709, 'mean_word_length': 5.080555555555556, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6851075', 'n_tokens_mistral': 878, 'n_tokens_neox': 825, 'n_words': 147}