diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/walking.cpp | 91 | ||||
-rw-r--r-- | engines/draci/walking.h | 9 |
2 files changed, 100 insertions, 0 deletions
diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp index 9868486c2d..0f2dda4b88 100644 --- a/engines/draci/walking.cpp +++ b/engines/draci/walking.cpp @@ -493,4 +493,95 @@ bool WalkingState::continueWalking() { return false; // finished } +Movement WalkingState::animationForDirection(const Common::Point &here, const Common::Point &there) { + const int dx = there.x - here.x; + const int dy = there.y - here.y; + if (abs(dx) >= abs(dy)) { + return dx >= 0 ? kMoveRight : kMoveLeft; + } else { + return dy >= 0 ? kMoveUp : kMoveDown; + } +} + +Movement WalkingState::transitionBetweenAnimations(Movement previous, Movement next) { + switch (next) { + case kMoveUp: + switch (previous) { + case kMoveLeft: + case kStopLeft: + case kSpeakLeft: + return kMoveLeftUp; + case kMoveRight: + case kStopRight: + case kSpeakRight: + return kMoveRightUp; + default: + return kMoveUndefined; + } + case kMoveDown: + switch (previous) { + case kMoveLeft: + case kStopLeft: + case kSpeakLeft: + return kMoveLeftDown; + case kMoveRight: + case kStopRight: + case kSpeakRight: + return kMoveRightDown; + default: + return kMoveUndefined; + } + case kMoveLeft: + switch (previous) { + case kMoveDown: + return kMoveDownLeft; + case kMoveUp: + return kMoveUpLeft; + case kMoveRight: + case kStopRight: + case kSpeakRight: + return kMoveRightLeft; + default: + return kMoveUndefined; + } + case kMoveRight: + switch (previous) { + case kMoveDown: + return kMoveDownRight; + case kMoveUp: + return kMoveUpRight; + case kMoveLeft: + case kStopLeft: + case kSpeakLeft: + return kMoveLeftRight; + default: + return kMoveUndefined; + } + case kStopLeft: + switch (previous) { + case kMoveUp: + return kMoveUpStopLeft; + case kMoveRight: + case kStopRight: + case kSpeakRight: + return kMoveRightLeft; + default: + return kMoveUndefined; + } + case kStopRight: + switch (previous) { + case kMoveUp: + return kMoveUpStopRight; + case kMoveLeft: + case kStopLeft: + case kSpeakLeft: + return kMoveLeftRight; + default: + return kMoveUndefined; + } + default: + return kMoveUndefined; + } +} + } diff --git a/engines/draci/walking.h b/engines/draci/walking.h index bc53231d5a..b85b77d53d 100644 --- a/engines/draci/walking.h +++ b/engines/draci/walking.h @@ -128,6 +128,15 @@ private: const GPL2Program *_callback; uint16 _callbackOffset; + + // Return one of the 4 animations kMove{Down,Up,Right,Left} + // corresponding to the walking from here to there. + static Movement animationForDirection(const Common::Point &here, const Common::Point &there); + + // Returns either animation that needs to be played between given two + // animations (e.g., kMoveRightDown after kMoveRight and before + // kMoveDown), or kMoveUndefined if none animation is to be played. + static Movement transitionBetweenAnimations(Movement previous, Movement next); }; } // End of namespace Draci |