[Scummvm-cvs-logs] SF.net SVN: scummvm:[46057] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Sun Nov 22 06:10:32 CET 2009
Revision: 46057
http://scummvm.svn.sourceforge.net/scummvm/?rev=46057&view=rev
Author: spalek
Date: 2009-11-22 05:10:31 +0000 (Sun, 22 Nov 2009)
Log Message:
-----------
Fix positioning of one-time hero animations.
With the previous code, the position of the animation was doubled (due to
counting the position twice, the second time being a relative shift), which
put it mostly outside the screen. This is because one-time hero animations
are actually stored using absolute coordinates.
Modified Paths:
--------------
scummvm/trunk/engines/draci/animation.cpp
scummvm/trunk/engines/draci/animation.h
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/script.cpp
Modified: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp 2009-11-22 02:42:15 UTC (rev 46056)
+++ scummvm/trunk/engines/draci/animation.cpp 2009-11-22 05:10:31 UTC (rev 46057)
@@ -43,6 +43,7 @@
_currentFrame = 0;
_hasChangedFrame = true;
_callback = &Animation::doNothing;
+ _isRelative = false;
}
Animation::~Animation() {
@@ -556,6 +557,7 @@
insert(anim, true);
anim->setLooping(cyclic);
+ anim->setIsRelative(relative);
for (uint i = 0; i < numFrames; ++i) {
uint spriteNum = animationReader.readUint16LE() - 1;
Modified: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/trunk/engines/draci/animation.h 2009-11-22 02:42:15 UTC (rev 46056)
+++ scummvm/trunk/engines/draci/animation.h 2009-11-22 05:10:31 UTC (rev 46057)
@@ -94,6 +94,8 @@
bool isLooping() const { return _looping; }
void setLooping(bool looping);
+ void setIsRelative(bool value) { _isRelative = value; }
+ bool isRelative() const { return _isRelative; }
void setRelative(int relx, int rely);
int getRelativeX() const { return _displacement.relX; }
int getRelativeY() const { return _displacement.relY; }
@@ -147,6 +149,7 @@
bool _hasChangedFrame;
Displacement _displacement;
+ bool _isRelative;
uint _tick;
bool _playing;
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2009-11-22 02:42:15 UTC (rev 46056)
+++ scummvm/trunk/engines/draci/game.cpp 2009-11-22 05:10:31 UTC (rev 46057)
@@ -1290,16 +1290,24 @@
_persons[kDragonObject]._x = _hero.x;
_persons[kDragonObject]._y = p.y;
- // Set the per-animation scaling factor
- anim->setScaleFactors(scale, scale);
+ if (anim->isRelative()) {
+ // Set the per-animation scaling factor and relative position
+ anim->setScaleFactors(scale, scale);
+ anim->setRelative(p.x, p.y);
- anim->setRelative(p.x, p.y);
+ // Clear the animation's shift so that the real sprite stays at place
+ // regardless of what the current phase is. If the animation starts
+ // from the beginning, the shift is already [0,0], but if it is in the
+ // middle, it may be different.
+ anim->clearShift();
- // Clear the animation's shift so that the real sprite stays at place
- // regardless of what the current phase is. If the animation starts
- // from the beginning, the shift is already [0,0], but if it is in the
- // middle, it may be different.
- anim->clearShift();
+ // Otherwise this dragon animation is used at exactly one place
+ // in the game (such as jumping into the secret entrance),
+ // which can is recognized by it using absolute coordinates.
+ // Bypass our animation positioning system, otherwise there two
+ // shifts will get summed and the animation will be placed
+ // outside the screen.
+ }
}
void Game::positionHeroAsAnim(Animation *anim) {
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2009-11-22 02:42:15 UTC (rev 46056)
+++ scummvm/trunk/engines/draci/script.cpp 2009-11-22 05:10:31 UTC (rev 46057)
@@ -338,8 +338,7 @@
const GameObject *obj = _vm->_game->getObject(objID);
- bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
-
+ const bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
if (objID == kDragonObject || visible) {
const int i = obj->playingAnim();
if (i >= 0) {
@@ -421,16 +420,15 @@
objID, obj->_title.c_str(), animID);
}
Animation *anim = obj->_anim[index];
-
- if (objID == kDragonObject)
- _vm->_game->positionAnimAsHero(anim);
-
anim->registerCallback(&Animation::stop);
- bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
-
- if (objID == kDragonObject || visible) {
- obj->playAnim(index);
+ if (objID == kDragonObject) {
+ _vm->_game->playHeroAnimation(index);
+ } else {
+ const bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
+ if (visible) {
+ obj->playAnim(index);
+ }
}
}
@@ -452,15 +450,15 @@
objID, obj->_title.c_str(), animID);
}
Animation *anim = obj->_anim[index];
-
- if (objID == kDragonObject)
- _vm->_game->positionAnimAsHero(anim);
-
anim->registerCallback(&Animation::exitGameLoop);
- bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
- if (objID == kDragonObject || visible) {
- obj->playAnim(index);
+ if (objID == kDragonObject) {
+ _vm->_game->playHeroAnimation(index);
+ } else {
+ const bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
+ if (visible) {
+ obj->playAnim(index);
+ }
}
// Runs an inner loop until the animation ends.
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