diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-05 21:31:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-05 21:31:10 +0300 |
commit | ac01c186d37b14da92314ff44b4e043b0c0ee31b (patch) | |
tree | d91ef52c51c44d14f85dc2ea6258ae8af612fb2f /src | |
parent | 9ac1ca5aa120263a1d19735eef6c9614306e45e0 (diff) | |
download | manaverse-ac01c186d37b14da92314ff44b4e043b0c0ee31b.tar.gz manaverse-ac01c186d37b14da92314ff44b4e043b0c0ee31b.tar.bz2 manaverse-ac01c186d37b14da92314ff44b4e043b0c0ee31b.tar.xz manaverse-ac01c186d37b14da92314ff44b4e043b0c0ee31b.zip |
add support for additinional diagonal moving speed.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 23 | ||||
-rw-r--r-- | src/being/being.h | 3 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 252de4c3b..73652bb1a 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -137,6 +137,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mType(type), mSpeechBubble(new SpeechBubble), mWalkSpeed(Net::getPlayerHandler()->getDefaultWalkSpeed()), + mSpeed(Net::getPlayerHandler()->getDefaultWalkSpeed().x), mIp(), mSpriteRemap(new int[20]), mSpriteHide(new int[20]), @@ -1345,10 +1346,15 @@ void Being::nextTile() return; } + mActionTime += static_cast<int>(mSpeed / 10); + if (mX != pos.x && mY != pos.y) + mSpeed = mWalkSpeed.x * 1.4; + else + mSpeed = mWalkSpeed.x; + mX = pos.x; mY = pos.y; setAction(MOVE); - mActionTime += static_cast<int>(mWalkSpeed.x / 10); } void Being::logic() @@ -1481,8 +1487,8 @@ void Being::logic() case MOVE: { - if (static_cast<float>(get_elapsed_time(mActionTime) - >= getWalkSpeed().x)) + if (static_cast<float>(get_elapsed_time( + mActionTime)) >= mSpeed) { nextTile(); } @@ -1528,10 +1534,9 @@ void Being::logic() if (frameCount < 10) frameCount = 10; - if (!isAlive() && getWalkSpeed().x - && Net::getGameHandler()->removeDeadBeings() + if (!isAlive() && mSpeed && Net::getGameHandler()->removeDeadBeings() && static_cast<int> ((static_cast<float>(get_elapsed_time(mActionTime)) - / static_cast<float>(getWalkSpeed().x))) >= frameCount) + / mSpeed)) >= frameCount) { if (mType != PLAYER && actorSpriteManager) actorSpriteManager->destroy(this); @@ -1627,11 +1632,9 @@ int Being::getOffset(const signed char pos, const signed char neg) const const int time = get_elapsed_time(mActionTime); offset = (pos == LEFT && neg == RIGHT) ? static_cast<int>((static_cast<float>(time) - * static_cast<float>(mMap->getTileWidth())) - / static_cast<float>(mWalkSpeed.x)) : + * static_cast<float>(mMap->getTileWidth())) / mSpeed) : static_cast<int>((static_cast<float>(time) - * static_cast<float>(mMap->getTileHeight())) - / static_cast<float>(mWalkSpeed.y)); + * static_cast<float>(mMap->getTileHeight())) / mSpeed); } // We calculate the offset _from_ the _target_ location diff --git a/src/being/being.h b/src/being/being.h index b08cba443..e373ec5e3 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -476,7 +476,7 @@ class Being : public ActorSprite, public ConfigListener * in tiles per second for Manaserv. */ void setWalkSpeed(const Vector &speed) - { mWalkSpeed = speed; } + { mWalkSpeed = speed; mSpeed = speed.x; } /** * Gets the walk speed. @@ -1000,6 +1000,7 @@ class Being : public ActorSprite, public ConfigListener * @see MILLISECONDS_IN_A_TICK */ Vector mWalkSpeed; + float mSpeed; std::string mIp; int *mSpriteRemap; int *mSpriteHide; |