aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/walking.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-11-05 00:21:54 +0000
committerRobert Špalek2009-11-05 00:21:54 +0000
commitfc2e2e27fc85b01b35f853bef8c93741162c4a81 (patch)
tree5bba9b69697d2f2739357ba0740ea6a1f8d72dec /engines/draci/walking.cpp
parent1f49679db5256221958bd336f47616a14b28b10f (diff)
downloadscummvm-rg350-fc2e2e27fc85b01b35f853bef8c93741162c4a81.tar.gz
scummvm-rg350-fc2e2e27fc85b01b35f853bef8c93741162c4a81.tar.bz2
scummvm-rg350-fc2e2e27fc85b01b35f853bef8c93741162c4a81.zip
Added helper functions for dragon animations
svn-id: r45677
Diffstat (limited to 'engines/draci/walking.cpp')
-rw-r--r--engines/draci/walking.cpp91
1 files changed, 91 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;
+ }
+}
+
}