summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-14 19:35:27 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-14 19:35:27 +0000
commit55494057bd7e1ae5e6260816b1c5b2a84e2ff573 (patch)
treee8dac9033909041361c1ca72d8955884f2a85b7f /src/being.cpp
parent1ccc963719897ca290104f42adc9c37b792feb7a (diff)
downloadmana-55494057bd7e1ae5e6260816b1c5b2a84e2ff573.tar.gz
mana-55494057bd7e1ae5e6260816b1c5b2a84e2ff573.tar.bz2
mana-55494057bd7e1ae5e6260816b1c5b2a84e2ff573.tar.xz
mana-55494057bd7e1ae5e6260816b1c5b2a84e2ff573.zip
Removed the rather useless remaining draw function from the engine class and
fixed an issue with fading out damage texts (they were sometimes fully opaque at the end of fading out).
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/being.cpp b/src/being.cpp
index b3cb9906..d4f68fac 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -62,7 +62,6 @@ Being::Being(Uint32 id, Uint16 job, Map *map):
mSex(2),
mSpeechTime(0),
mDamageTime(0),
- mShowSpeech(false), mShowDamage(false),
mPx(0), mPy(0),
mSprites(VECTOREND_SPRITE, NULL),
mEquipmentSpriteIDs(VECTOREND_SPRITE, 0)
@@ -134,16 +133,14 @@ void
Being::setSpeech(const std::string &text, Uint32 time)
{
mSpeech = text;
- mSpeechTime = tick_time;
- mShowSpeech = true;
+ mSpeechTime = 500;
}
void
Being::setDamage(Sint16 amount, Uint32 time)
{
mDamage = amount ? toString(amount) : "miss";
- mDamageTime = tick_time;
- mShowDamage = true;
+ mDamageTime = 300;
}
void
@@ -297,17 +294,13 @@ Being::nextStep()
void
Being::logic()
{
- // Determine whether speech should still be displayed
- if (get_elapsed_time(mSpeechTime) > 5000)
- {
- mShowSpeech = false;
- }
+ // Reduce the time that speech is still displayed
+ if (mSpeechTime > 0)
+ mSpeechTime--;
- // Determine whether damage should still be displayed
- if (get_elapsed_time(mDamageTime) > 3000)
- {
- mShowDamage = false;
- }
+ // Reduce the time that damage is still displayed
+ if (mDamageTime > 0)
+ mDamageTime--;
// Update pixel coordinates
mPx = mX * 32 + getXOffset();
@@ -365,7 +358,7 @@ Being::drawSpeech(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
int py = mPy + offsetY;
// Draw speech above this being
- if (mShowSpeech)
+ if (mSpeechTime > 0)
{
graphics->setFont(speechFont);
graphics->setColor(gcn::Color(255, 255, 255));
@@ -373,7 +366,7 @@ Being::drawSpeech(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
}
// Draw damage above this being
- if (mShowDamage && get_elapsed_time(mDamageTime) > 250)
+ if (mDamageTime > 0 && mDamageTime < 275)
{
// Selecting the right color
if (mDamage == "miss")
@@ -390,13 +383,13 @@ Being::drawSpeech(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
}
int textY = (getType() == MONSTER) ? 32 : 70;
- int ft = get_elapsed_time(mDamageTime) - 1500;
- float a = (ft > 0) ? 1.0 - ft / 1500.0 : 1.0;
+ int ft = 150 - mDamageTime;
+ float a = (ft > 0) ? 1.0 - ft / 150.0 : 1.0;
graphics->setColor(gcn::Color(255, 255, 255, (int)(255 * a)));
graphics->drawText(mDamage,
px + 16,
- py - textY - get_elapsed_time(mDamageTime) / 100,
+ py - textY - (300 - mDamageTime) / 10,
gcn::Graphics::CENTER);
// Reset alpha value