aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorDenis Kasak2009-07-25 04:36:43 +0000
committerDenis Kasak2009-07-25 04:36:43 +0000
commit20baaf93f5df7871e93162db479fe1ab526fe35c (patch)
tree671559284a77e4164706e1942c94be0b14ed42c8 /engines/draci
parent22c372137f2649fa614966b24918064c2bb44726 (diff)
downloadscummvm-rg350-20baaf93f5df7871e93162db479fe1ab526fe35c.tar.gz
scummvm-rg350-20baaf93f5df7871e93162db479fe1ab526fe35c.tar.bz2
scummvm-rg350-20baaf93f5df7871e93162db479fe1ab526fe35c.zip
* Moved walking code to Game::walkHero().
* Implemented WalkOn GPL command. * Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing). svn-id: r42735
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp55
-rw-r--r--engines/draci/game.h2
-rw-r--r--engines/draci/script.cpp17
-rw-r--r--engines/draci/script.h1
4 files changed, 46 insertions, 29 deletions
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) {
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 5898c04bd0..d8e0d137b7 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -187,6 +187,8 @@ public:
return n;
}
+ void walkHero(int x, int y);
+
void loadRoom(int roomNum);
int loadAnimation(uint animNum, uint z);
void loadOverlays();
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 1d2f4a8892..6177a71a49 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -58,9 +58,9 @@ void Script::setupCommandList() {
{ 9, 3, "ResetDialogue", 0, { 0 }, NULL },
{ 9, 4, "ResetDialogueFrom", 0, { 0 }, NULL },
{ 9, 5, "ResetBlock", 1, { 3 }, NULL },
- { 10, 1, "WalkOn", 3, { 1, 1, 3 }, NULL },
- { 10, 2, "StayOn", 3, { 1, 1, 3 }, NULL },
- { 10, 3, "WalkOnPlay", 3, { 1, 1, 3 }, NULL },
+ { 10, 1, "WalkOn", 3, { 1, 1, 3 }, &Script::walkOn },
+ { 10, 2, "StayOn", 3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation
+ { 10, 3, "WalkOnPlay", 3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation
{ 11, 1, "LoadPalette", 1, { 2 }, NULL },
{ 12, 1, "SetPalette", 0, { 0 }, NULL },
{ 12, 2, "BlackPalette", 0, { 0 }, NULL },
@@ -402,6 +402,17 @@ void Script::execUse(Common::Queue<int> &params) {
run(obj->_program, obj->_use);
}
+void Script::walkOn(Common::Queue<int> &params) {
+ if (_vm->_game->getLoopStatus() == kStatusInventory) {
+ return;
+ }
+
+ int x = params.pop();
+ int y = params.pop();
+ params.pop(); // facing direction, not used yet
+
+ _vm->_game->walkHero(x, y);
+}
/**
* @brief Evaluates mathematical expressions
* @param reader Stream reader set to the beginning of the expression
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 11a1c6f3a8..7ed194f68d 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -111,6 +111,7 @@ private:
void execInit(Common::Queue<int> &params);
void execLook(Common::Queue<int> &params);
void execUse(Common::Queue<int> &params);
+ void walkOn(Common::Queue<int> &params);
int operAnd(int op1, int op2);
int operOr(int op1, int op2);