-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmitter.cpp
More file actions
104 lines (78 loc) · 1.82 KB
/
Emitter.cpp
File metadata and controls
104 lines (78 loc) · 1.82 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Emitter.cpp
* openFrameworks
*
* Created by Joshua Walton on 6/14/08.
* Copyright 2008 Lab at Rockwell Group. All rights reserved.
*
*
*/
#include "emitter.h"
#include <iostream>
//#include "Agent.h"
Emitter::Emitter(bool _recycles, int _timeToLive, ofxVec3f _tPos) {
origPos = _tPos;
pos = origPos;
recycles = _recycles;
timeToLive = _timeToLive;
timeStarted = ofGetElapsedTimeMillis();
cout<<"CREATING AN EMITTER"<<endl;
//create(_numParticles);
}
void Emitter::addParticle(Agent *_tAgent) {
//tempParticle = new Particle(pos, timeToLive);
// push onto the vector stack
agentContainer.push_back(_tAgent);
//cout<<"added a partcle"<<endl;
}
void Emitter::update() {
// Make sure we delete the particles if we need to
for(int i =0; i<agentContainer.size(); i++) {
agentContainer[i]->update();
/*
if (particleContainer[i]->isDead() == true) {
// kill it
cout<<"Is dead"<<endl;
//delete particleContainer[i];
//particleContainer.erase(particleContainer.begin()+i);
//particleContainer[i]->recycle();
}
*/
}
cout <<"IAM EMITTER"<<endl;
}
void Emitter::draw() {
for(int i =0; i<agentContainer.size(); i++) {
agentContainer[i]->draw();
}
}
/*
void Emitter::create(int numParticles) {
for (int i=0; i<numParticles; i++) {
addParticle();
}
}
*/
void Emitter::destroy() {
for(int i =0; i<agentContainer.size(); i++) {
cout<<"DELETED HERE"<<endl;
//delete particleContainer[i];
//particleContainer.erase(particleContainer.begin()+i);
}
}
void Emitter::killParticle() {
}
bool Emitter::isDead() {
// if it never dies then we don't have to check it has timed out.
/*
if (recycles == true) {
if (ofGetElapsedTimeMillis() > timeStarted + timeToLive ) {
cout<<"DESTROYED!"<<endl;
destroy();
return true;
} else {
return false;
}
}
*/
}