demo2's little "bug"(explosion smoke display)

You are viewing a static copy of the old 2DBoy forum, which closed in 2010. It is preserved here for historical interest, but it is not possible to reply to topics. For more recent discussion about World of Goo, visit our new forum.
demo2's little "bug"(explosion smoke display)gravity11/07/2010 - 07:27

framework's demo2 game is cool and had not something wrong with demo2. but when I implement my own explosion effect(copy the demo2's code to my project), and I found my game had something strange when displayed the explosion's smoke, and I fixed it.

the code(Explosion.cpp line:29 ):
<br />float alpha = 1 - (Boy::Environment::instance()->getTime() - mStartTime) / mDuration;<br />g->setAlpha(alpha);<br />g->setDrawMode(Boy::Graphics::DRAWMODE_ADDITIVE);<br />for (int i=0 ; i<NUM_PARTICLES ; i++)<br />{<br />    g->pushTransform();<br />    g->translate(<br />        mParticlePositions[i].x,<br />        mParticlePositions[i].y);<br />    g->drawImage(mImage);<br />    g->popTransform();<br />}<br />g->setColorizationEnabled(false);<br />g->setDrawMode(Boy::Graphics::DRAWMODE_NORMAL);<br />

should be modified to
<br />float alpha = 1 - (Boy::Environment::instance()->getTime() - mStartTime) / mDuration;<br />if ( alpha < 0 )       //changed here.............<br />    alpha = 0;<br />g->setAlpha(alpha);<br />g->setDrawMode(Boy::Graphics::DRAWMODE_ADDITIVE);<br />for (int i=0 ; i<NUM_PARTICLES ; i++)<br />{<br />    g->pushTransform();<br />    g->translate(<br />        mParticlePositions[i].x,<br /> mParticlePositions[i].y);<br />    g->drawImage(mImage);<br />    g->popTransform();<br />}<br />g->setAlpha(1);                // and here........<br />g->setColorizationEnabled(false);<br />g->setDrawMode(Boy::Graphics::DRAWMODE_NORMAL);<br />

hope it helpful. :)
and sorry for my bad English.


Last modified Sun, 11/07/2010 - 07:33 by gravity