summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-04-08 10:21:13 +0000
committerAaron Marks <nymacro@gmail.com>2005-04-08 10:21:13 +0000
commit722538cb38196237c0d503e8c07b3408c17989bc (patch)
tree851430d69fc7d7926adc7bfc3e94723999795609 /src
parent7c2c4d75a1f459b46c08883c282af0afb61fceb9 (diff)
downloadmana-722538cb38196237c0d503e8c07b3408c17989bc.tar.gz
mana-722538cb38196237c0d503e8c07b3408c17989bc.tar.bz2
mana-722538cb38196237c0d503e8c07b3408c17989bc.tar.xz
mana-722538cb38196237c0d503e8c07b3408c17989bc.zip
Created damage text seperate from speech & made it scroll.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp19
-rw-r--r--src/being.h13
-rw-r--r--src/game.cpp4
3 files changed, 33 insertions, 3 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 1f8cbd40..fd369a42 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -123,7 +123,8 @@ Being::Being():
emotion(0), emotion_time(0),
text_x(0), text_y(0),
hair_style(1), hair_color(1),
- weapon(0)
+ weapon(0),
+ damage(""), damage_time(0), damage_y(0.0)
{
}
@@ -158,6 +159,12 @@ void Being::setSpeech(const std::string &text, int time)
speech_time = time;
}
+void Being::setDamage(const std::string &text, int time)
+{
+ damage = text;
+ damage_time = time;
+}
+
void Being::nextStep()
{
if (!path.empty())
@@ -214,6 +221,13 @@ void Being::drawSpeech(Graphics *graphics)
gcn::Graphics::CENTER);
//}
}
+ if (damage_time > 0.0) {
+ graphics->drawText(damage,
+ text_x + 60, text_y - 60 - (int)damage_y,
+ gcn::Graphics::CENTER);
+ damage_y += 0.5;
+ } else
+ damage_y = 0;
}
void Being::tick()
@@ -221,4 +235,7 @@ void Being::tick()
if (speech_time > 0) {
speech_time--;
}
+ if (damage_time > 0) {
+ damage_time--;
+ }
}
diff --git a/src/being.h b/src/being.h
index 7c816cee..10d1a47c 100644
--- a/src/being.h
+++ b/src/being.h
@@ -43,6 +43,10 @@ class Being {
std::string speech;
unsigned char speech_time;
+ std::string damage;
+ unsigned char damage_time;
+ float damage_y; //Y coord of damage text
+
public:
unsigned int id;
unsigned short job;
@@ -91,6 +95,15 @@ class Being {
void setSpeech(const std::string &text, int time);
/**
+ * Puts a damage bubble above this being for the specified amount
+ * of time.
+ *
+ * @param text The text that should appear.
+ * @param time The amount of time the text should stay in milliseconds.
+ */
+ void setDamage(const std::string &text, int time);
+
+ /**
* Sets the hair color for this being.
*/
void setHairColor(int color);
diff --git a/src/game.cpp b/src/game.cpp
index d4e1ed6f..9670b11b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1043,12 +1043,12 @@ void do_parse() {
if (RFIFOW(22) == 0) {
// Yellow
- being->setSpeech("miss", SPEECH_TIME);
+ being->setDamage("miss", SPEECH_TIME);
} else {
// Blue for monster, red for player
std::stringstream ss;
ss << RFIFOW(22);
- being->setSpeech(ss.str(), SPEECH_TIME);
+ being->setDamage(ss.str(), SPEECH_TIME);
}
if (RFIFOL(2) != player_node->id) { // buggy