aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-07-18 03:00:12 +0000
committerDenis Kasak2009-07-18 03:00:12 +0000
commit94417e77438e779ee1a03e366d96dc49bff04e03 (patch)
treee145c4630fe0403f5678406b53b76e3a66e5bd93 /engines
parent3cde84fec4a06c9a95d8f6e2f61a3a990c8f3bff (diff)
downloadscummvm-rg350-94417e77438e779ee1a03e366d96dc49bff04e03.tar.gz
scummvm-rg350-94417e77438e779ee1a03e366d96dc49bff04e03.tar.bz2
scummvm-rg350-94417e77438e779ee1a03e366d96dc49bff04e03.zip
* Added support for "walking" with the hero (i.e. moving the sprite to locations allowed by the walking map)
* Enabled drawing the walking map with the 'w' hotkey for testing svn-id: r42581
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/draci.cpp13
-rw-r--r--engines/draci/game.cpp45
2 files changed, 52 insertions, 6 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index b2b0083c22..1e7b292229 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -171,6 +171,7 @@ int DraciEngine::go() {
Common::Event event;
bool quit = false;
+ bool showWalkingMap = false;
while (!quit) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
@@ -182,7 +183,17 @@ int DraciEngine::go() {
_game->changeRoom(_game->nextRoomNum());
else if (event.kbd.keycode == Common::KEYCODE_LEFT)
_game->changeRoom(_game->prevRoomNum());
- break;
+ else if (event.kbd.keycode == Common::KEYCODE_w) { // Show walking map toggle
+ // Toggle
+ showWalkingMap = !showWalkingMap;
+
+ if (showWalkingMap) {
+ _anims->play(-2);
+ } else {
+ _anims->stop(-2);
+ }
+ }
+ break;
default:
_mouse->handleEvent(event);
}
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 28448835be..161f1d82d7 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -155,6 +155,7 @@ void Game::init() {
debugC(4, kDraciLogicDebugLevel, "Running init program for the dragon object...");
_vm->_script->run(dragon->_program, dragon->_init);
+ _currentRoom._roomNum = _info._startRoom;
changeRoom(_info._startRoom);
_vm->_mouse->setCursorType(kNormalCursor);
@@ -165,7 +166,22 @@ 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)) {
+
+ int animID = getObject(kDragonObject)->_anims[0];
+
+ Animation *anim = _vm->_anims->getAnimation(animID);
+ Drawable *frame = anim->getFrame();
+ y -= frame->getHeight();
+
+ // HACK: Z needs to be handled according to Y position
+ anim->setZ(256);
+
+ anim->setRelative(x, y);
+
+ _vm->_anims->play(animID);
+
debugC(4, kDraciLogicDebugLevel, "Walk to x: %d y: %d", x, y);
}
}
@@ -221,7 +237,6 @@ void Game::loadRoom(int roomNum) {
debugC(4, kDraciLogicDebugLevel, "EscRoom: %d", _currentRoom._escRoom);
debugC(4, kDraciLogicDebugLevel, "Gates: %d", _currentRoom._numGates);
-
// Set cursor state
if (_currentRoom._mouseOn) {
debugC(6, kDraciLogicDebugLevel, "Mouse: ON");
@@ -231,7 +246,6 @@ void Game::loadRoom(int roomNum) {
_vm->_mouse->cursorOff();
}
-
Common::Array<int> gates;
for (uint i = 0; i < _currentRoom._numGates; ++i) {
@@ -276,6 +290,23 @@ void Game::loadRoom(int roomNum) {
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
_vm->_screen->setPalette(f->_data, 0, kNumColours);
+
+ // HACK: Create a visible overlay from the walking map so we can test it
+ byte *wlk = new byte[kScreenWidth * kScreenHeight];
+ memset(wlk, 255, kScreenWidth * kScreenHeight);
+
+ for (uint i = 0; i < kScreenWidth; ++i) {
+ for (uint j = 0; j < kScreenHeight; ++j) {
+ if (_currentRoom._walkingMap.isWalkable(i, j)) {
+ wlk[j * kScreenWidth + i] = 2;
+ }
+ }
+ }
+
+ Sprite *ov = new Sprite(wlk, kScreenWidth, kScreenHeight, 0, 0, false);
+
+ Animation *map = _vm->_anims->addAnimation(-2, 255, false);
+ map->addFrame(ov);
}
int Game::loadAnimation(uint animNum, uint z) {
@@ -404,17 +435,20 @@ void Game::changeRoom(uint roomNum) {
_vm->_screen->clearScreen();
_vm->_anims->deleteOverlays();
+
+ // Delete walking map testing overlay
+ _vm->_anims->deleteAnimation(-2);
int oldRoomNum = _currentRoom._roomNum;
for (uint i = 0; i < _info._numObjects; ++i) {
GameObject *obj = &_objects[i];
-
- if (i != 0 && obj->_location == oldRoomNum) {
+
+ if (i != 0 && (obj->_location == oldRoomNum)) {
for (uint j = 0; j < obj->_anims.size(); ++j) {
_vm->_anims->deleteAnimation(obj->_anims[j]);
- obj->_anims.pop_back();
}
+ obj->_anims.clear();
}
}
@@ -459,4 +493,5 @@ bool WalkingMap::isWalkable(int x, int y) {
return mapByte & (1 << pixelIndex % 8);
}
+
}