summaryrefslogtreecommitdiff
path: root/particles.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2010-08-18 14:38:34 +0000
committerIan C <ianc@noddybox.co.uk>2010-08-18 14:38:34 +0000
commit19bbd5822593c7198dd54eb0f5d38fa1ed8d8fb7 (patch)
tree97f7f8849c3a8282ba571a64ff2a655cdf5d41aa /particles.cpp
parent0d2f672482fee91a9642a7cb6eb01fcdded79159 (diff)
Reformatted code and altered the attraction rule to something a bit more
correct. Also added two tests to prove it works.
Diffstat (limited to 'particles.cpp')
-rw-r--r--particles.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/particles.cpp b/particles.cpp
index 2603397..2bd9139 100644
--- a/particles.cpp
+++ b/particles.cpp
@@ -66,13 +66,13 @@ void Particles::draw()
glBegin(GL_LINES);
for(i=m_list.begin();i!=m_list.end();i++)
- {
+ {
i->a-=m_alpha_dec;
glColor4f(i->r,i->g,i->b,i->a);
glVertex3f(i->x1,i->y1,i->z1);
glVertex3f(i->x2,i->y2,i->z2);
- }
+ }
glEnd();
}
@@ -85,17 +85,19 @@ void Particles::update()
// Delete dead particles
//
i=m_list.begin();
-
+
while ((i!=m_list.end())&&(i->a<=m_alpha_min))
- {
+ {
m_list.pop_front();
i=m_list.begin();
- }
+ }
// Update them
//
for(i=m_list.begin();i!=m_list.end();i++)
+ {
i->a-=m_alpha_dec;
+ }
}
// END OF FILE //