aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorRobert Špalek2009-11-07 01:54:47 +0000
committerRobert Špalek2009-11-07 01:54:47 +0000
commit638305fcbb9a1c53425b546a0deb2ea6c3208f5a (patch)
tree7560bb0553fbdfff85b89c76efca41cb0c550977 /engines
parent357d9989d4c6ae73e02a044b388f36069e093ce0 (diff)
downloadscummvm-rg350-638305fcbb9a1c53425b546a0deb2ea6c3208f5a.tar.gz
scummvm-rg350-638305fcbb9a1c53425b546a0deb2ea6c3208f5a.tar.bz2
scummvm-rg350-638305fcbb9a1c53425b546a0deb2ea6c3208f5a.zip
The hero turns the right direction after walking
svn-id: r45713
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/game.cpp3
-rw-r--r--engines/draci/walking.cpp21
-rw-r--r--engines/draci/walking.h7
3 files changed, 17 insertions, 14 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index ed5768fd42..baaca70508 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -983,7 +983,8 @@ void Game::setHeroPosition(const Common::Point &p) {
void Game::positionHero(const Common::Point &p, SightDirection dir) {
setHeroPosition(p);
- playHeroAnimation(_walkingState.animationForSightDirection(dir));
+ Common::Point mousePos(_vm->_mouse->getPosX(), _vm->_mouse->getPosY());
+ playHeroAnimation(_walkingState.animationForSightDirection(dir, _hero, mousePos, WalkingPath()));
}
Common::Point Game::findNearestWalkable(int x, int y) const {
diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp
index 9edffc6996..fc194bf9d8 100644
--- a/engines/draci/walking.cpp
+++ b/engines/draci/walking.cpp
@@ -435,7 +435,7 @@ void WalkingState::startWalking(const Common::Point &p1, const Common::Point &p2
_dir = dir;
if (!_path.size()) {
- return;
+ _path.push_back(p1);
}
if (_path.size() == 1 && p2 != p1) {
// Although the first and last point belong to the same
@@ -611,7 +611,7 @@ Movement WalkingState::animationForDirection(const Common::Point &here, const Co
Movement WalkingState::directionForNextPhase() const {
if (_segment >= (int) (_path.size() - 2)) {
- return animationForSightDirection(_dir);
+ return animationForSightDirection(_dir, _path[_path.size()-1], _mouse, _path);
} else {
return animationForDirection(_path[_segment+1], _path[_segment+2]);
}
@@ -698,24 +698,23 @@ Movement WalkingState::transitionBetweenAnimations(Movement previous, Movement n
}
}
-Movement WalkingState::animationForSightDirection(SightDirection dir) const {
+Movement WalkingState::animationForSightDirection(SightDirection dir, const Common::Point &hero, const Common::Point &mouse, const WalkingPath &path) const {
switch (dir) {
+ case kDirectionMouse:
+ return mouse.x < hero.x ? kStopLeft : kStopRight;
case kDirectionLeft:
return kStopLeft;
case kDirectionRight:
return kStopRight;
default: {
- const GameObject *dragon = _vm->_game->getObject(kDragonObject);
- const int anim_index = _vm->_game->playingObjectAnimation(dragon);
- if (anim_index >= 0) {
- return static_cast<Movement> (anim_index);
- } else {
- return kStopRight; // TODO
+ // Find the last horizontal direction on the path.
+ int i = path.size() - 1;
+ while (i >= 0 && path[i].x == hero.x) {
+ --i;
}
- break;
+ return (i >= 0 && path[i].x < hero.x) ? kStopRight : kStopLeft;
}
}
- // TODO: implement all needed functionality
}
}
diff --git a/engines/draci/walking.h b/engines/draci/walking.h
index 180c3cf855..6c8d9b9b07 100644
--- a/engines/draci/walking.h
+++ b/engines/draci/walking.h
@@ -128,8 +128,11 @@ public:
// scheduled animation.
void heroAnimationFinished();
- // Returns the hero's animation corresponding to looking into given direction.
- Movement animationForSightDirection(SightDirection dir) const;
+ // Returns the hero's animation corresponding to looking into given
+ // direction. The direction can be smart and in that case this
+ // function needs to know the whole last path, the current position of
+ // the hero, or the mouse position.
+ Movement animationForSightDirection(SightDirection dir, const Common::Point &hero, const Common::Point &mouse, const WalkingPath &path) const;
private:
DraciEngine *_vm;