diff options
-rw-r--r-- | engines/draci/game.cpp | 32 | ||||
-rw-r--r-- | engines/draci/game.h | 11 |
2 files changed, 40 insertions, 3 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index a0e0acbe85..58eb10a0ce 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -52,9 +52,9 @@ Game::Game(DraciEngine *vm) : _vm(vm) { _persons = new Person[numPersons]; for (i = 0; i < numPersons; ++i) { - _persons[i]._x = personData.readByte(); - _persons[i]._y = personData.readByte(); - _persons[i]._fontColour = personData.readUint16LE(); + _persons[i]._x = personData.readUint16LE(); + _persons[i]._y = personData.readUint16LE(); + _persons[i]._fontColour = personData.readByte(); } // Close persons file @@ -277,6 +277,21 @@ void Game::loop() { debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor); } + if (_loopSubstatus == kStatusTalk) { + Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText); + Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame()); + + uint speechDuration = kBaseSpeechDuration + + speechFrame->getLength() * kSpeechTimeUnit / + (128 / 16 + 1); + + if ((_vm->_system->getMillis() - _speechTick) >= speechDuration) { + _shouldExitLoop = true; + } else { + _shouldExitLoop = false; + } + } + if (shouldQuit()) return; @@ -324,6 +339,9 @@ void Game::walkHero(int x, int y) { // Fetch base height of the frame uint height = frame->getHeight(); + _persons[kDragonObject]._x = x; + _persons[kDragonObject]._y = y - lround(scaleY) * height; + // 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 @@ -727,6 +745,14 @@ int Game::getIconStatus(int iconID) { return _iconStatus[iconID]; } +Person *Game::getPerson(int personID) { + return &_persons[personID]; +} + +void Game::setSpeechTick(uint tick) { + _speechTick = tick; +} + /** * The GPL command Mark sets the animation index (which specifies the order in which * animations were loaded in) which is then used by the Release command to delete diff --git a/engines/draci/game.h b/engines/draci/game.h index a38b71a256..33b6e76894 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -47,6 +47,11 @@ enum { kNotFound = -1 }; +enum SpeechConstants { + kBaseSpeechDuration = 200, + kSpeechTimeUnit = 400 +}; + class WalkingMap { public: @@ -204,6 +209,8 @@ public: int getVariable(int varNum); void setVariable(int varNum, int value); + Person *getPerson(int personID); + int getRoomNum(); void setRoomNum(int room); @@ -228,6 +235,8 @@ public: void runGateProgram(int gate); + void setSpeechTick(uint tick); + bool _roomChange; private: @@ -252,6 +261,8 @@ private: bool _shouldQuit; bool _shouldExitLoop; + uint _speechTick; + int _objUnderCursor; int _markedAnimationIndex; //!< Used by the Mark GPL command }; |