aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-07-22 07:18:00 +0000
committerDenis Kasak2009-07-22 07:18:00 +0000
commitef37d0a9b05607141558ba358a7dfd361aa26d9e (patch)
tree15aa0d212fbed7d171665fed367cf16179ecb772 /engines/draci/game.cpp
parent5a77f089e1c6ea851851c55084a12023380656f1 (diff)
downloadscummvm-rg350-ef37d0a9b05607141558ba358a7dfd361aa26d9e.tar.gz
scummvm-rg350-ef37d0a9b05607141558ba358a7dfd361aa26d9e.tar.bz2
scummvm-rg350-ef37d0a9b05607141558ba358a7dfd361aa26d9e.zip
* Stopped AnimationManager::drawScene() from marking its own dirtiness.
* Instead, Animation::nextFrame() marks both the old and the new frame dirty. This makes it possible to only update the real screen when the animation changes and results in a pretty big speedup. * Added utility method Animation::markDirtyRect() which takes a (Surface *) and marks a dirty rect on it for the current frame. * Fixed artifacts when moving the dragon. svn-id: r42652
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index c01e544986..360375f0b8 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -181,7 +181,22 @@ void Game::loop() {
double scaleX = _currentRoom._pers0 + _currentRoom._persStep * y;
double scaleY = scaleX;
- Drawable *frame;
+ // Set the Z coordinate for the dragon's animation
+ anim->setZ(y+1);
+
+ // Fetch current frame
+ Drawable *frame = anim->getFrame();
+
+ // Fetch base height of the frame
+ uint height = frame->getHeight();
+
+ // 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
+ // We also need to do this before we change the frames' scaled dimensions
+ // so setRelative() can correctly delete the old frame
+ y -= scaleY * height;
+ anim->setRelative(x, y);
// Set the scaled dimensions for all frames
for (uint i = 0; i < anim->getFramesNum(); ++i) {
@@ -194,15 +209,6 @@ void Game::loop() {
frame->setScaled(scaledWidth, scaledHeight);
}
- // Set the Z coordinate for the dragon's animation
- anim->setZ(y+1);
-
- // 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 -= frame->getScaledHeight();
- anim->setRelative(x, y);
-
// Play the animation
_vm->_anims->play(animID);