diff options
Diffstat (limited to 'src/imageparticle.cpp')
-rw-r--r-- | src/imageparticle.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp index 86e7e50f..410782bd 100644 --- a/src/imageparticle.cpp +++ b/src/imageparticle.cpp @@ -18,6 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Id$ */ #include "imageparticle.h" @@ -37,31 +38,26 @@ void ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const if (!mAlive) return; - int screenX = (int)mPosX + offsetX - mImage->getWidth()/2; - int screenY = (int)mPosY - int(mPosZ) + offsetY - mImage->getHeight()/2; + int screenX = (int) mPosX + offsetX - mImage->getWidth() / 2; + int screenY = (int) mPosY - (int) mPosZ + offsetY - mImage->getHeight()/2; - // check if on screen - if (screenX + mImage->getWidth() < 0 || + // Check if on screen + if (screenX + mImage->getWidth() < 0 || screenX > graphics->getWidth() || screenY + mImage->getHeight() < 0 || screenY > graphics->getHeight()) + { return; + } float alphafactor = 1.0f; if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut) - alphafactor *= ((float)mLifetimeLeft / (float)mFadeOut); + alphafactor *= (float) mLifetimeLeft / (float) mFadeOut; if (mLifetimePast < mFadeIn) - alphafactor *= ((float)mLifetimePast / (float)mFadeIn); + alphafactor *= (float) mLifetimePast / (float) mFadeIn; - if (alphafactor < 1.0f) { - graphics->drawImageTransparent(mImage, - screenX, - screenY, - alphafactor - ); - } else { - graphics->drawImage(mImage, screenX, screenY); - } + mImage->setAlpha(alphafactor); + graphics->drawImage(mImage, screenX, screenY); } |