[Scummvm-cvs-logs] SF.net SVN: scummvm:[45713] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sat Nov 7 02:54:47 CET 2009


Revision: 45713
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45713&view=rev
Author:   spalek
Date:     2009-11-07 01:54:47 +0000 (Sat, 07 Nov 2009)

Log Message:
-----------
The hero turns the right direction after walking

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/walking.cpp
    scummvm/trunk/engines/draci/walking.h

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-11-07 01:28:27 UTC (rev 45712)
+++ scummvm/trunk/engines/draci/game.cpp	2009-11-07 01:54:47 UTC (rev 45713)
@@ -983,7 +983,8 @@
 
 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 {

Modified: scummvm/trunk/engines/draci/walking.cpp
===================================================================
--- scummvm/trunk/engines/draci/walking.cpp	2009-11-07 01:28:27 UTC (rev 45712)
+++ scummvm/trunk/engines/draci/walking.cpp	2009-11-07 01:54:47 UTC (rev 45713)
@@ -435,7 +435,7 @@
 	_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::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::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
 }
 
 }

Modified: scummvm/trunk/engines/draci/walking.h
===================================================================
--- scummvm/trunk/engines/draci/walking.h	2009-11-07 01:28:27 UTC (rev 45712)
+++ scummvm/trunk/engines/draci/walking.h	2009-11-07 01:54:47 UTC (rev 45713)
@@ -128,8 +128,11 @@
 	// 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;


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