diff options
-rw-r--r-- | INSTALL | 12 | ||||
-rw-r--r-- | src/being.cpp | 50 | ||||
-rw-r--r-- | src/being.h | 15 | ||||
-rw-r--r-- | src/engine.cpp | 33 | ||||
-rw-r--r-- | src/main.cpp | 2 |
5 files changed, 61 insertions, 51 deletions
@@ -46,14 +46,14 @@ with "tmw". By default all files are installed to /usr/local, you can pass a different prefix to configure as usual. - EXPERIMENTAL: For those people with modern video cards and fast OpenGL - performance, we have been working on OpenGL support. At the moment there is - no way to switch between SDL and OpenGL dynamically and you need to do this - at compile time. To try this perform step 3 as follows: + NOTE: For those people with modern video cards and fast OpenGL performance, + we have been working on OpenGL support. At the moment there is no way to + switch between SDL and OpenGL dynamically and you need to do this at compile + time. To try this perform step 3 as follows: - "./configure CXXFLAGS=-DUSE_OPENGL" + "./configure --with-opengl" - And rebuild the executable from scratch using "make clean" and then "make". + Rebuild the executable from scratch using "make clean" and then "make". 3. Notes diff --git a/src/being.cpp b/src/being.cpp index 00d06a15..8fe61f14 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -40,8 +40,9 @@ PATH_NODE::PATH_NODE(unsigned short x, unsigned short y): void add_node(Being *being) { beings.push_back(being); + // If the being is a player, request the name - if (being-> job < 10) { + if (being->isPlayer()) { WFIFOW(0) = net_w_value(0x0094); WFIFOL(2) = net_l_value(RFIFOL(2)); WFIFOSET(6); @@ -96,7 +97,7 @@ unsigned int findPlayer(unsigned short x, unsigned short y) for (i = beings.begin(); i != beings.end(); i++) { Being *being = (*i); // Check if is a player - if (being->job < 10 && being->x == x && being->y == y) { + if (being->isPlayer() && being->x == x && being->y == y) { return being->id; } } @@ -109,7 +110,7 @@ unsigned int findMonster(unsigned short x, unsigned short y) for (i = beings.begin(); i != beings.end(); i++) { Being *being = (*i); // Check if is a MONSTER that is alive - if (being->job > 200 && being->x == x && being->y == y && + if (being->isMonster() && being->x == x && being->y == y && being->action != MONSTER_DEAD) { return being->id; @@ -164,11 +165,11 @@ Being::Being(): emotion(0), emotion_time(0), text_x(0), text_y(0), weapon(0), + aspd(350), + hairStyle(1), hairColor(1), speech_time(0), damage_time(0), - showSpeech(false), showDamage(false), - aspd(350), - hairStyle(1), hairColor(1) + showSpeech(false), showDamage(false) { strcpy(name, ""); } @@ -204,7 +205,7 @@ void Being::setDestination(int destX, int destY) void Being::setHairColor(int color) { hairColor = color; - if (hairColor < 1 || hairColor > 11) + if (hairColor < 1 || hairColor > NR_HAIR_COLORS + 1) { hairColor = 1; } @@ -286,6 +287,41 @@ void Being::nextStep() frame = 0; } +void Being::logic() +{ + if (isPlayer()) + { + switch (action) { + case WALK: + frame = (get_elapsed_time(walk_time) * 4) / speed; + if (frame >= 4) { + nextStep(); + } + break; + case ATTACK: + frame = (get_elapsed_time(walk_time) * 4) / aspd; + if (frame >= 4) { + nextStep(); + } + break; + } + + if (emotion != 0) { + emotion_time--; + if (emotion_time == 0) { + emotion = 0; + } + } + } + + if (get_elapsed_time(speech_time) > 5000) { + showSpeech = false; + } + if (get_elapsed_time(damage_time) > 3000) { + showDamage = false; + } +} + void Being::drawSpeech(Graphics *graphics) { // Draw speech above this being diff --git a/src/being.h b/src/being.h index 8224a729..a2390f89 100644 --- a/src/being.h +++ b/src/being.h @@ -56,14 +56,11 @@ class Being unsigned short speed; unsigned char emotion; unsigned char emotion_time; - unsigned int text_x, text_y; // temp solution to fix speech position + unsigned int text_x, text_y; // temp solution to fix speech position unsigned short weapon; char name[24]; - unsigned int speech_time; - unsigned int damage_time; - bool showSpeech, showDamage; - unsigned short aspd; // attack speed + unsigned short aspd; /**< Attack speed */ /** * Constructor. @@ -136,6 +133,11 @@ class Being void nextStep(); /** + * Performs being logic. + */ + void logic(); + + /** * Draws the speech text above the being. */ void drawSpeech(Graphics *graphics); @@ -165,6 +167,9 @@ class Being std::string speech; std::string damage; unsigned short hairStyle, hairColor; + unsigned int speech_time; + unsigned int damage_time; + bool showSpeech, showDamage; }; /** Add a Being to the list */ diff --git a/src/engine.cpp b/src/engine.cpp index adda6d06..2d93a842 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -272,38 +272,7 @@ void Engine::logic() { Being *being = (*beingIterator); - if (being->job < 10) { // A player - switch (being->action) { - case WALK: - being->frame = (get_elapsed_time(being->walk_time) * 4) / - (being->speed); - if (being->frame >= 4) { - being->nextStep(); - } - break; - case ATTACK: - being->frame = (get_elapsed_time(being->walk_time) * 4) / - (being->aspd); - if (being->frame >= 4) { - being->nextStep(); - } - break; - default: - break; - } - - if (being->emotion != 0) { - being->emotion_time--; - if (being->emotion_time == 0) { - being->emotion = 0; - } - } - } - - if (get_elapsed_time(being->speech_time) > 5000) - being->showSpeech = false; - if (get_elapsed_time(being->damage_time) > 3000) - being->showDamage = false; + being->logic(); if (being->action == MONSTER_DEAD && being->frame >= 20) { delete being; diff --git a/src/main.cpp b/src/main.cpp index 923ceb9c..daa41569 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -250,7 +250,7 @@ void init_engine() const SDL_VideoInfo *vi = SDL_GetVideoInfo(); logger->log("Possible to create hardware surfaces: %s", - ((vi->hw_available) ? "yes" : "no ")); + ((vi->hw_available) ? "yes" : "no")); logger->log("Window manager available: %s", ((vi->wm_available) ? "yes" : "no")); logger->log("Accelerated hardware to hardware blits: %s", |