diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-23 20:41:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-23 20:41:50 +0300 |
commit | bac1df3b9ac0e3327e8de812793d0a18cfd64cba (patch) | |
tree | 46cf157684952f5aeccd59875917abb222024df8 /src/gui/viewport.cpp | |
parent | 7d60bf1c04fce4ed16144aece76e594e0e217960 (diff) | |
download | plus-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.gz plus-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.bz2 plus-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.xz plus-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.zip |
Add moving camera commands from npc.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1407415fd..f4c6c315f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -875,3 +875,44 @@ bool Viewport::isPopupMenuVisible() { return mPopupMenu ? mPopupMenu->isVisible() : false; } + +void Viewport::moveCameraToActor(int actorId, int x, int y) +{ + if (!player_node) + return; + + Actor *actor = actorSpriteManager->findBeing(actorId); + if (!actor) + return; + Vector actorPos = actor->getPosition(); + Vector playerPos = player_node->getPosition(); + mCameraMode = 1; + mCameraRelativeX = actorPos.x - playerPos.x + x; + mCameraRelativeY = actorPos.y - playerPos.y + y; +} + +void Viewport::moveCameraToPosition(int x, int y) +{ + if (!player_node) + return; + + Vector playerPos = player_node->getPosition(); + mCameraMode = 1; + + mCameraRelativeX = x - playerPos.x; + mCameraRelativeY = y - playerPos.y; +} + +void Viewport::moveCameraRelative(int x, int y) +{ + mCameraMode = 1; + mCameraRelativeX += x; + mCameraRelativeY += y; +} + +void Viewport::returnCamera() +{ + mCameraMode = 0; + mCameraRelativeX = 0; + mCameraRelativeY = 0; +} |