From 1ddb44f5caf3e0bc93b7d19cc6e227b10e4b4c41 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Wed, 23 May 2007 21:22:43 +0000 Subject: Made text splash effects fade out. --- src/particle.cpp | 6 ++++-- src/textparticle.cpp | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/particle.cpp b/src/particle.cpp index bb28c873..579bbfc1 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -146,7 +146,6 @@ Particle::update() { if (mInvDieDistance > 0.0f && invHypotenuse > mInvDieDistance) { - logger->log("killed"); mAlive = false; } float accFactor = invHypotenuse * mAcceleration; @@ -179,7 +178,8 @@ Particle::update() if (mPosZ > PARTICLE_SKY || mPosZ < 0.0f) { - if (mBounce && fabs(mVectorZ) > mGravity * 2) { + if (mBounce > 0.0f) + { mPosZ *= -mBounce; mVectorX *= mBounce; mVectorY *= mBounce; @@ -326,6 +326,8 @@ Particle::addTextSplashEffect(std::string text, gcn::Font *font, gcn::Color colo ); newParticle->setGravity(0.1f); newParticle->setBounce(0.5f); + newParticle->setLifetime(200); + newParticle->setFadeOut(100); mChildParticles.push_back(newParticle); diff --git a/src/textparticle.cpp b/src/textparticle.cpp index e7a0926b..2a2c50e8 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -42,7 +42,22 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const int screenX = (int)mPosX + offsetX; int screenY = (int)mPosY - int(mPosZ) + offsetY; + int alpha = 255; + + if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut) + { + alpha *= mLifetimeLeft; + alpha /= mFadeOut; + }; + + if (mLifetimePast < mFadeIn) + { + alpha *= mLifetimePast; + alpha /= mFadeIn; + } + graphics->setFont(mTextFont); - graphics->setColor(mTextColor); + graphics->setColor(gcn::Color (mTextColor.r, mTextColor.g, mTextColor.b, + alpha)); graphics->drawText(mText, screenX, screenY, gcn::Graphics::CENTER); } -- cgit v1.2.3-70-g09d2