From 20baaf93f5df7871e93162db479fe1ab526fe35c Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sat, 25 Jul 2009 04:36:43 +0000 Subject: * Moved walking code to Game::walkHero(). * Implemented WalkOn GPL command. * Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing). svn-id: r42735 --- engines/draci/game.cpp | 55 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'engines/draci/game.cpp') diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index d7ae538209..5cfbefebad 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -171,41 +171,44 @@ void Game::loop() { 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) { -- cgit v1.2.3