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. --- sparks.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sparks.cpp') diff --git a/sparks.cpp b/sparks.cpp index 6a1484b..096e12a 100644 --- a/sparks.cpp +++ b/sparks.cpp @@ -27,7 +27,7 @@ static const char id[]="$Id$"; #include "sparks.h" Sparks::Sparks(int num, GLfloat alpha_dec, GLfloat alpha_min, - int len, GLfloat delta) + int len, GLfloat delta) { m_num=max(num,1); m_alpha_dec=alpha_dec; @@ -53,7 +53,7 @@ void Sparks::add(GLfloat ox, GLfloat oy, GLfloat oz) p.life=m_life; for(f=0;falpha<=m_alpha_min)) - { + { m_list.pop_front(); i=m_list.begin(); - } + } // Update them // for(i=m_list.begin();i!=m_list.end();i++) - { + { i->x1+=i->dx; i->y1+=i->dy; i->z1+=i->dz; @@ -96,7 +96,7 @@ void Sparks::update() i->z2+=i->dz; i->alpha-=m_alpha_dec; - } + } } @@ -109,12 +109,12 @@ void Sparks::draw() glBegin(GL_LINES); for(i=m_list.begin();i!=m_list.end();i++) - { + { glColor4f(1.0,1.0,0.0,i->alpha); glVertex3f(i->x1,i->y1,i->z1); glColor4f(0.5,0.0,0.0,i->alpha); glVertex3f(i->x2,i->y2,i->z2); - } + } glEnd(); } -- cgit v1.2.3