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

spalek at users.sourceforge.net spalek at users.sourceforge.net
Tue Sep 29 07:54:59 CEST 2009


Revision: 44456
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44456&view=rev
Author:   spalek
Date:     2009-09-29 05:54:59 +0000 (Tue, 29 Sep 2009)

Log Message:
-----------
Clean up and unify positioning dragon's animations

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

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-09-29 00:03:09 UTC (rev 44455)
+++ scummvm/trunk/engines/draci/game.cpp	2009-09-29 05:54:59 UTC (rev 44456)
@@ -985,59 +985,23 @@
 
 	Surface *surface = _vm->_screen->getSurface();
 	
-	Common::Point p = _currentRoom._walkingMap.findNearestWalkable(x, y, surface->getRect());
+	_hero = _currentRoom._walkingMap.findNearestWalkable(x, y, surface->getRect());
 
-	_heroX = p.x;
-	_heroY = p.y;
-
 	GameObject *dragon = getObject(kDragonObject); 
 
 	for (uint i = 0; i < dragon->_anims.size(); ++i) {
 		_vm->_anims->stop(dragon->_anims[i]);
 	}
 
-	debugC(3, kDraciLogicDebugLevel, "Walk to x: %d y: %d", _heroX, _heroY);
+	debugC(3, kDraciLogicDebugLevel, "Walk to x: %d y: %d", _hero.x, _hero.y);
 
 	// Fetch dragon's animation ID
 	// FIXME: Need to add proper walking (this only warps the dragon to position)
 	int animID = dragon->_anims[0];
 
 	Animation *anim = _vm->_anims->getAnimation(animID);
+	positionAnimAsHero(anim);
 
-	// Calculate scaling factors
-	const double scale = _vm->_game->getPers0() + _vm->_game->getPersStep() * _heroY;
-
-	// Set the Z coordinate for the dragon's animation
-	anim->setZ(y+1);
-
-	// Fetch current frame
-	Drawable *frame = anim->getFrame();
-
-	// Fetch base dimensions of the frame
-	uint height = frame->getHeight();
-	uint width = frame->getWidth();
-
-	// 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
-	_heroY -= (int)(scale * height);
-	_heroX -= (int)(scale * width) / 2;
-
-	// TODO: Check if underflow is handled well everywhere and remove this once sure
-
-	if (_heroX < 0)
-		_heroX = 0;
-
-	// Since _persons[] is used for placing talking text, we use the non-adjusted x value
-	// so the text remains centered over the dragon.
-  	_persons[kDragonObject]._x = p.x;
-	_persons[kDragonObject]._y = _heroY;
-
-	// Set the per-animation scaling factor
-	anim->setScaleFactors(scale, scale);
-
-	anim->setRelative(_heroX, _heroY);
-
 	// Play the animation
 	_vm->_anims->play(animID);
 }
@@ -1396,16 +1360,11 @@
 
 void Game::positionAnimAsHero(Animation *anim) {
 
-	// Fetch dragon's coordinates
-	int x = _heroX;
-	int y = _heroY;
-
 	// Calculate scaling factors
-	const double scaleX = getPers0() + getPersStep() * y;
-	const double scaleY = scaleX;
+	const double scale = getPers0() + getPersStep() * _hero.y;
 
 	// Set the Z coordinate for the dragon's animation
-	anim->setZ(y+1);
+	anim->setZ(_hero.y + 1);
 
 	// Fetch current frame
 	Drawable *frame = anim->getFrame();
@@ -1414,27 +1373,33 @@
 	uint height = frame->getHeight();
 	uint width = frame->getWidth();
 
-	// Set the per-animation scaling factor
-	anim->setScaleFactors(scaleX, scaleY);
-
-  	_persons[kDragonObject]._x = x + (lround(scaleX) * width) / 2;
-	_persons[kDragonObject]._y = y - lround(scaleY) * height;
-
 	// 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);
-	x -= (int)(scaleX * width) / 2;
+	Common::Point p = _hero;
+	p.x -= (int)(scale * width) / 2;
+	p.y -= (int)(scale * height);
+	// TODO: fix drawScaled() and remove this
+	if (p.x < 0)
+		p.x = 0;
 
-	anim->setRelative(x, y);
+	// Since _persons[] is used for placing talking text, we use the non-adjusted x value
+	// so the text remains centered over the dragon.
+  	_persons[kDragonObject]._x = _hero.x;
+	_persons[kDragonObject]._y = p.y;
+
+	// Set the per-animation scaling factor
+	anim->setScaleFactors(scale, scale);
+
+	anim->setRelative(p.x, p.y);
 }
 
 int Game::getHeroX() const {
-	return _heroX;
+	return _hero.x;
 }
 
 int Game::getHeroY() const {
-	return _heroY;
+	return _hero.y;
 }
 
 double Game::getPers0() const {

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-09-29 00:03:09 UTC (rev 44455)
+++ scummvm/trunk/engines/draci/game.h	2009-09-29 05:54:59 UTC (rev 44456)
@@ -352,7 +352,7 @@
 
 	GameInfo _info;
 
-	int _heroX, _heroY;
+	Common::Point _hero;
 
 	int *_variables;
 	Person *_persons;


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