From ef37d0a9b05607141558ba358a7dfd361aa26d9e Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Wed, 22 Jul 2009 07:18:00 +0000 Subject: * 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 --- engines/draci/game.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'engines/draci/game.cpp') 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); -- cgit v1.2.3