aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorDenis Kasak2009-07-17 00:20:57 +0000
committerDenis Kasak2009-07-17 00:20:57 +0000
commite419110569067fe98a0b009ee5a7e90b507aea49 (patch)
tree4e34afa654ad1685cfb07a308c5300061ec31c74 /engines/draci
parentc420a4fba13e8f1307b2325d22d2a928d95d1cee (diff)
downloadscummvm-rg350-e419110569067fe98a0b009ee5a7e90b507aea49.tar.gz
scummvm-rg350-e419110569067fe98a0b009ee5a7e90b507aea49.tar.bz2
scummvm-rg350-e419110569067fe98a0b009ee5a7e90b507aea49.zip
* Added Game::loop()
* Added WalkingMap::isWalkable() * Renamed remaining _priority identifiers to _z which were left by mistake in the previous commit svn-id: r42546
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/draci.cpp1
-rw-r--r--engines/draci/game.cpp24
-rw-r--r--engines/draci/game.h6
-rw-r--r--engines/draci/script.cpp2
4 files changed, 31 insertions, 2 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 339962ac52..045640f568 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -155,6 +155,7 @@ int DraciEngine::go() {
_mouse->handleEvent(event);
}
}
+ _game->loop();
_anims->drawScene(_screen->getSurface());
_screen->copyToScreen();
_system->delayMillis(20);
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 53c0f903fc..d80408b649 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -146,6 +146,17 @@ void Game::init() {
_vm->_mouse->setCursorType(kNormalCursor);
}
+void Game::loop() {
+
+ if (_currentRoom._mouseOn) {
+ int x = _vm->_mouse->getPosX();
+ int y = _vm->_mouse->getPosY();
+ if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) {
+ debugC(4, kDraciLogicDebugLevel, "Walk to x: %d y: %d", x, y);
+ }
+ }
+}
+
void Game::loadRoom(int roomNum) {
BAFile *f;
@@ -427,4 +438,17 @@ GameObject::~GameObject() {
delete[] _program._bytecode;
}
+bool WalkingMap::isWalkable(int x, int y) {
+
+ // Convert to map pixels
+ x = x / _deltaX;
+ y = y / _deltaY;
+
+ int pixelIndex = _mapWidth * y + x;
+ int byteIndex = pixelIndex / 8;
+ int mapByte = _data[byteIndex];
+
+ return mapByte & (1 << pixelIndex % 8);
+}
+
}
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 950fe4c817..6a4285f6b0 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -60,6 +60,8 @@ public:
_realWidth = mapReader.readUint16LE();
_realHeight = mapReader.readUint16LE();
+ _deltaX = mapReader.readUint16LE();
+ _deltaY = mapReader.readUint16LE();
_mapWidth = mapReader.readUint16LE();
_mapHeight = mapReader.readUint16LE();
_byteWidth = mapReader.readUint16LE();
@@ -68,6 +70,7 @@ public:
_data = data + mapReader.pos();
}
+ bool isWalkable(int x, int y);
private:
int _realWidth, _realHeight;
@@ -137,6 +140,7 @@ public:
~Game();
void init();
+ void loop();
void changeRoom(uint roomNum);
@@ -186,7 +190,7 @@ private:
uint16 *_dialogOffsets;
byte *_iconStatus;
GameObject *_objects;
- Room _currentRoom;
+ Room _currentRoom;
};
} // End of namespace Draci
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index d22b7b4941..2d0a33db86 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -270,7 +270,7 @@ void Script::load(Common::Queue<int> &params) {
GameObject *obj = _vm->_game->getObject(objID);
- _vm->_game->loadAnimation(animID, obj->_priority);
+ _vm->_game->loadAnimation(animID, obj->_z);
obj->_anims.push_back(animID);
}