From 19bbd5822593c7198dd54eb0f5d38fa1ed8d8fb7 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 18 Aug 2010 14:38:34 +0000 Subject: Reformatted code and altered the attraction rule to something a bit more correct. Also added two tests to prove it works. --- particles.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'particles.cpp') 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 // -- cgit v1.2.3