-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticlesManager.cpp
47 lines (40 loc) · 1 KB
/
ParticlesManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Author: JoseGuilhermeCR
Copyright 2017
*/
#include "include/ParticlesManager.h"
ParticlesManager::ParticlesManager()
:
m_particles()
{
}
void ParticlesManager::update(float deltaTime)
{
// Iterate over each particle system and update it
for (unsigned int i = 0; i < m_particles.size(); ++i)
{
m_particles.at(i).update(deltaTime);
if (m_particles.at(i).shouldDelete())
{
m_particles.erase(m_particles.begin() + i);
--i;
continue;
}
}
}
void ParticlesManager::draw(sf::RenderWindow& window)
{
// Draw the particle effects if needed
for (unsigned int i = 0; i < m_particles.size(); ++i)
{
m_particles.at(i).draw(window);
}
}
void ParticlesManager::reset()
{
m_particles.clear();
}
void ParticlesManager::spawnParticleSystem(unsigned int number, float x, float y, float lifeTime)
{
m_particles.push_back(Particles(number, x, y, lifeTime));
}