[Scummvm-cvs-logs] SF.net SVN: scummvm:[45677] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Thu Nov 5 01:21:54 CET 2009
Revision: 45677
http://scummvm.svn.sourceforge.net/scummvm/?rev=45677&view=rev
Author: spalek
Date: 2009-11-05 00:21:54 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
Added helper functions for dragon animations
Modified Paths:
--------------
scummvm/trunk/engines/draci/walking.cpp
scummvm/trunk/engines/draci/walking.h
Modified: scummvm/trunk/engines/draci/walking.cpp
===================================================================
--- scummvm/trunk/engines/draci/walking.cpp 2009-11-05 00:04:53 UTC (rev 45676)
+++ scummvm/trunk/engines/draci/walking.cpp 2009-11-05 00:21:54 UTC (rev 45677)
@@ -493,4 +493,95 @@
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;
+ }
+}
+
+}
Modified: scummvm/trunk/engines/draci/walking.h
===================================================================
--- scummvm/trunk/engines/draci/walking.h 2009-11-05 00:04:53 UTC (rev 45676)
+++ scummvm/trunk/engines/draci/walking.h 2009-11-05 00:21:54 UTC (rev 45677)
@@ -128,6 +128,15 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list