[Scummvm-cvs-logs] SF.net SVN: scummvm:[42735] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sat Jul 25 06:36:44 CEST 2009


Revision: 42735
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42735&view=rev
Author:   dkasak13
Date:     2009-07-25 04:36:43 +0000 (Sat, 25 Jul 2009)

Log Message:
-----------
* Moved walking code to Game::walkHero().
* Implemented WalkOn GPL command.
* Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing).

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/game.h
    scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/script.h

Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-25 04:23:59 UTC (rev 42734)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-25 04:36:43 UTC (rev 42735)
@@ -171,41 +171,44 @@
 		int y = _vm->_mouse->getPosY();
 
 		if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) {
-			
-			// Fetch dragon's animation ID
-			// FIXME: Need to add proper walking (this only warps the dragon to position)
-			int animID = getObject(kDragonObject)->_anims[0];
+			walkHero(x, y);
+		}
+	}
+}
 
-			Animation *anim = _vm->_anims->getAnimation(animID);
+void Game::walkHero(int x, int y) {
+	// Fetch dragon's animation ID
+	// FIXME: Need to add proper walking (this only warps the dragon to position)
+	int animID = getObject(kDragonObject)->_anims[0];
 
-			// Calculate scaling factors
-			double scaleX = _currentRoom._pers0 + _currentRoom._persStep * y;
-			double scaleY = scaleX;
+	Animation *anim = _vm->_anims->getAnimation(animID);
 
-			// Set the Z coordinate for the dragon's animation
-			anim->setZ(y+1);
+	// Calculate scaling factors
+	double scaleX = _currentRoom._pers0 + _currentRoom._persStep * y;
+	double scaleY = scaleX;
 
-			// Fetch current frame
-			Drawable *frame = anim->getFrame();
+	// Set the Z coordinate for the dragon's animation
+	anim->setZ(y+1);
 
-			// Fetch base height of the frame
-			uint height = frame->getHeight();
+	// Fetch current frame
+	Drawable *frame = anim->getFrame();
 
-			// We naturally want the dragon to position its feet to the location of the
-			// click but sprites are drawn from their top-left corner so we subtract
-			// the current height of the dragon's sprite
-			y -= (int)(scaleY * height);
-			anim->setRelative(x, y);
+	// Fetch base height of the frame
+	uint height = frame->getHeight();
 
-			// Set the per-animation scaling factor
-			anim->setScaleFactors(scaleX, scaleY);
+	// We naturally want the dragon to position its feet to the location of the
+	// click but sprites are drawn from their top-left corner so we subtract
+	// the current height of the dragon's sprite
+	y -= (int)(scaleY * height);
+	anim->setRelative(x, y);
 
-			// Play the animation
-			_vm->_anims->play(animID);
+	// Set the per-animation scaling factor
+	anim->setScaleFactors(scaleX, scaleY);
 
-			debugC(4, kDraciLogicDebugLevel, "Walk to x: %d y: %d", x, y);
-		}
-	}
+	// Play the animation
+	_vm->_anims->play(animID);
+
+	debugC(4, kDraciLogicDebugLevel, "Walk to x: %d y: %d", x, y);
 }
 
 void Game::loadRoom(int roomNum) {

Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.h	2009-07-25 04:23:59 UTC (rev 42734)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.h	2009-07-25 04:36:43 UTC (rev 42735)
@@ -187,6 +187,8 @@
 		return n;
 	}
 
+	void walkHero(int x, int y);
+
 	void loadRoom(int roomNum);
 	int loadAnimation(uint animNum, uint z);
 	void loadOverlays();

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-25 04:23:59 UTC (rev 42734)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-25 04:36:43 UTC (rev 42735)
@@ -58,9 +58,9 @@
 		{ 9,  3, "ResetDialogue", 		0, { 0 }, NULL },
 		{ 9,  4, "ResetDialogueFrom", 	0, { 0 }, NULL },
 		{ 9,  5, "ResetBlock", 			1, { 3 }, NULL },
-		{ 10, 1, "WalkOn", 				3, { 1, 1, 3 }, NULL },
-		{ 10, 2, "StayOn", 				3, { 1, 1, 3 }, NULL },
-		{ 10, 3, "WalkOnPlay", 			3, { 1, 1, 3 }, NULL },
+		{ 10, 1, "WalkOn", 				3, { 1, 1, 3 }, &Script::walkOn },
+		{ 10, 2, "StayOn", 				3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation
+		{ 10, 3, "WalkOnPlay", 			3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation
 		{ 11, 1, "LoadPalette", 		1, { 2 }, NULL },
 		{ 12, 1, "SetPalette", 			0, { 0 }, NULL },
 		{ 12, 2, "BlackPalette", 		0, { 0 }, NULL },
@@ -402,6 +402,17 @@
 	run(obj->_program, obj->_use);
 }
 
+void Script::walkOn(Common::Queue<int> &params) {
+	if (_vm->_game->getLoopStatus() == kStatusInventory) {
+		return;
+	}
+
+	int x = params.pop();
+	int y = params.pop();
+	params.pop(); // facing direction, not used yet
+
+	_vm->_game->walkHero(x, y);
+}
 /**
  * @brief Evaluates mathematical expressions
  * @param reader Stream reader set to the beginning of the expression

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-07-25 04:23:59 UTC (rev 42734)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-07-25 04:36:43 UTC (rev 42735)
@@ -111,6 +111,7 @@
 	void execInit(Common::Queue<int> &params);
 	void execLook(Common::Queue<int> &params);
 	void execUse(Common::Queue<int> &params);
+	void walkOn(Common::Queue<int> &params);
 
 	int operAnd(int op1, int op2);
 	int operOr(int op1, int op2);


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