diff options
author | Johannes Schickel | 2008-05-02 15:39:51 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-05-02 15:39:51 +0000 |
commit | 5e4fceec2eb837257386f790d920eadf483da3cf (patch) | |
tree | 38f440c89b59dca258225d64c78b86e11c4954a9 /engines/kyra/kyra_v2.cpp | |
parent | c6830b4138be54e056a7cf18b6b900c3e46ab4ff (diff) | |
download | scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.tar.gz scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.tar.bz2 scummvm-rg350-5e4fceec2eb837257386f790d920eadf483da3cf.zip |
Moved some character code from kyra2/kyra3 to KyraEngine_v2.
svn-id: r31822
Diffstat (limited to 'engines/kyra/kyra_v2.cpp')
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index ac8ae55bea..b8ede4f50b 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -39,6 +39,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _itemListSize = 0; _characterShapeFile = -1; + + _updateCharPosNextUpdate = 0; } KyraEngine_v2::~KyraEngine_v2() { @@ -146,5 +148,57 @@ uint8 *KyraEngine_v2::getShapePtr(int shape) const { return iter->_value; } +void KyraEngine_v2::moveCharacter(int facing, int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::moveCharacter(%d, %d, %d)", facing, x, y); + x &= ~3; + y &= ~1; + _mainCharacter.facing = facing; + + Screen *scr = screen(); + scr->hideMouse(); + switch (facing) { + case 0: + while (_mainCharacter.y1 > y) + updateCharPosWithUpdate(); + break; + + case 2: + while (_mainCharacter.x1 < x) + updateCharPosWithUpdate(); + break; + + case 4: + while (_mainCharacter.y1 < y) + updateCharPosWithUpdate(); + break; + + case 6: + while (_mainCharacter.x1 > x) + updateCharPosWithUpdate(); + break; + + default: + break; + } + scr->showMouse(); +} + +void KyraEngine_v2::updateCharPosWithUpdate() { + debugC(9, kDebugLevelMain, "KyraEngine_v2::updateCharPosWithUpdate()"); + updateCharPos(0, 0); + update(); +} + +int KyraEngine_v2::updateCharPos(int *table, int force) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::updateCharPos(%p, %d)", (const void*)table, force); + if (_updateCharPosNextUpdate > _system->getMillis() && !force) + return 0; + _mainCharacter.x1 += _updateCharPosXTable[_mainCharacter.facing]; + _mainCharacter.y1 += _updateCharPosYTable[_mainCharacter.facing]; + updateCharAnimFrame(0, table); + _updateCharPosNextUpdate = _system->getMillis() + getCharacterWalkspeed() * _tickLength; + return 1; +} + } // end of namespace Kyra |