summaryrefslogtreecommitdiff
path: root/src/textparticle.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-06-04 21:48:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-06-04 21:48:47 +0000
commita353543dd4da3c489a84f6f17125fdd0e1be2349 (patch)
tree5e447a0f9a3fd50f58a48f39bbb77d392d78af36 /src/textparticle.cpp
parentab072dddb231895ba7b6762eda9fa70af961b0fb (diff)
downloadmana-a353543dd4da3c489a84f6f17125fdd0e1be2349.tar.gz
mana-a353543dd4da3c489a84f6f17125fdd0e1be2349.tar.bz2
mana-a353543dd4da3c489a84f6f17125fdd0e1be2349.tar.xz
mana-a353543dd4da3c489a84f6f17125fdd0e1be2349.zip
Merged 0.0 changes from revision 3234 to 3317 to trunk.
Diffstat (limited to 'src/textparticle.cpp')
-rw-r--r--src/textparticle.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
new file mode 100644
index 00000000..dd01d2fe
--- /dev/null
+++ b/src/textparticle.cpp
@@ -0,0 +1,64 @@
+/*
+ * The Mana World
+ * Copyright 2006 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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 "textparticle.h"
+
+#include "graphics.h"
+
+TextParticle::TextParticle(Map *map, const std::string &text,
+ int colorR, int colorG, int colorB, gcn::Font *font):
+ Particle(map),
+ mText(text),
+ mTextFont(font),
+ mColorR(colorR),
+ mColorG(colorG),
+ mColorB(colorB)
+{
+}
+
+void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
+{
+ if (!mAlive)
+ return;
+
+ 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(gcn::Color (mColorR, mColorG, mColorB, alpha));
+ graphics->drawText(mText, screenX, screenY, gcn::Graphics::CENTER);
+}