-
Notifications
You must be signed in to change notification settings - Fork 1
/
SmokeEmitter.cpp
56 lines (37 loc) · 1.11 KB
/
SmokeEmitter.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
48
49
50
51
52
53
54
55
/*
* SmokeEmitter.cpp
*
* Created on: 2011-02-22
* Author: zapo
*/
#include "SmokeEmitter.h"
#include "VectorUtils.h"
#include "Particle.h"
#include <iostream>
SmokeEmitter::SmokeEmitter(int minTTL, int maxTTL) :
Emitter(sf::Shape()),
particleColor(sf::Color::White),
maxTTL(maxTTL),
minTTL(minTTL) {
}
SmokeEmitter::~SmokeEmitter() {
// TODO Auto-generated destructor stub
}
void SmokeEmitter::UpdateParticle(ParticlePtr & particle, float dt) const {
particle->SetRotation(sf::Randomizer::Random(particle->GetRotation() - 3, particle->GetRotation() + 3));
particle->Move(particle->GetDirection() * particle->GetVelocity() * dt);
}
void SmokeEmitter::InitParticle(ParticlePtr & particle) const {
particle->SetVelocity(sf::Randomizer::Random(100.f, 400.f));
particle->SetColor(particleColor);
particle->SetPosition(emissionPoint);
particle->SetRotation(angle);
particle->SetTTL(sf::Randomizer::Random(minTTL, maxTTL));
}
void SmokeEmitter::SetParticleColor(const sf::Color & color) {
particleColor = color;
}
void SmokeEmitter::SetTTLRange(int min, int max) {
minTTL = min;
maxTTL = max;
}