aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorRobert Špalek2009-11-03 21:05:26 +0000
committerRobert Špalek2009-11-03 21:05:26 +0000
commit9ad5e7461fed883710a0937a919cbee911a6e0a8 (patch)
tree2f7af38bc2df80a1a5cbf37fcad8f68071a688e1 /engines
parent45308a2bd5e2aa0cff92375fac877a0b1a166d93 (diff)
downloadscummvm-rg350-9ad5e7461fed883710a0937a919cbee911a6e0a8.tar.gz
scummvm-rg350-9ad5e7461fed883710a0937a919cbee911a6e0a8.tar.bz2
scummvm-rg350-9ad5e7461fed883710a0937a919cbee911a6e0a8.zip
Let setPath() store path with pixel precision, and update the map sprite when reloaded
svn-id: r45640
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/game.cpp19
-rw-r--r--engines/draci/walking.cpp23
-rw-r--r--engines/draci/walking.h3
3 files changed, 37 insertions, 8 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 3aad401ca2..cec92bc275 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -980,7 +980,7 @@ void Game::walkHero(int x, int y, SightDirection dir) {
redrawWalkingPath(kWalkingObliquePathOverlay, kWalkingObliquePathOverlayColour, obliquePath);
}
- _walkingState.setPath(obliquePath);
+ _walkingState.setPath(_hero, target, _walkingMap.getDelta(), obliquePath);
// FIXME: Need to add proper walking (this only warps the dragon to position)
_hero = target;
@@ -1097,22 +1097,21 @@ void Game::loadRoom(int roomNum) {
_currentRoom._gates.push_back(roomReader.readSint16LE());
}
- // Load the walking map
- loadWalkingMap(getMapID());
-
// Add overlays for the walking map and shortest/obliqued paths.
Animation *map = _vm->_anims->addAnimation(kWalkingMapOverlay, 256, _vm->_showWalkingMap);
- Sprite *ov = _walkingMap.newOverlayFromMap(kWalkingMapOverlayColour);
- map->addFrame(ov, NULL);
+ map->addFrame(NULL, NULL); // rewritten below by loadWalkingMap()
Animation *sPath = _vm->_anims->addAnimation(kWalkingShortestPathOverlay, 257, _vm->_showWalkingMap);
Animation *oPath = _vm->_anims->addAnimation(kWalkingObliquePathOverlay, 258, _vm->_showWalkingMap);
WalkingPath emptyPath;
- ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
+ Sprite *ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
sPath->addFrame(ov, NULL);
ov = _walkingMap.newOverlayFromPath(emptyPath, 0);
oPath->addFrame(ov, NULL);
+ // Load the walking map
+ loadWalkingMap(getMapID());
+
// Load the room's objects
for (uint i = 0; i < _info._numObjects; ++i) {
debugC(7, kDraciLogicDebugLevel,
@@ -1254,6 +1253,12 @@ void Game::loadWalkingMap(int mapID) {
const BAFile *f;
f = _vm->_walkingMapsArchive->getFile(mapID);
_walkingMap.load(f->_data, f->_length);
+
+ Animation *anim = _vm->_anims->getAnimation(kWalkingMapOverlay);
+ Sprite *ov = _walkingMap.newOverlayFromMap(kWalkingMapOverlayColour);
+ delete anim->getFrame(0);
+ anim->replaceFrame(0, ov, NULL);
+ anim->markDirtyRect(_vm->_screen->getSurface());
}
void Game::loadOverlays() {
diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp
index 372901e5f7..87cd1b3284 100644
--- a/engines/draci/walking.cpp
+++ b/engines/draci/walking.cpp
@@ -420,4 +420,27 @@ bool WalkingMap::managedToOblique(WalkingPath *path) const {
return improved;
}
+void WalkingState::setPath(const Common::Point &p1, const Common::Point &p2, const Common::Point &delta, const WalkingPath& path) {
+ _path = path;
+ if (!_path.size()) {
+ return;
+ }
+ if (_path.size() == 1 && p2 != p1) {
+ // Although the first and last point belong to the same
+ // rectangle and therefore the computed path is of length 1,
+ // they are different pixels.
+ _path.push_back(p2);
+ }
+
+ // The first and last point are available with pixel accurracy.
+ _path[0] = p1;
+ _path[_path.size() - 1] = p2;
+ // The intermediate points are given with map granularity; convert them
+ // to pixels.
+ for (uint i = 1; i < _path.size() - 1; ++i) {
+ _path[i].x *= delta.x;
+ _path[i].y *= delta.y;
+ }
+}
+
}
diff --git a/engines/draci/walking.h b/engines/draci/walking.h
index 247f57b4c9..104e9ed955 100644
--- a/engines/draci/walking.h
+++ b/engines/draci/walking.h
@@ -51,6 +51,7 @@ public:
bool findShortestPath(Common::Point p1, Common::Point p2, WalkingPath *path) const;
void obliquePath(const WalkingPath& path, WalkingPath *obliquedPath);
Sprite *newOverlayFromPath(const WalkingPath &path, byte colour) const;
+ Common::Point getDelta() const { return Common::Point(_deltaX, _deltaY); }
private:
int _realWidth, _realHeight;
@@ -98,7 +99,7 @@ public:
WalkingState() : _path() {}
~WalkingState() {}
- void setPath(const WalkingPath& path) { _path = path; }
+ void setPath(const Common::Point &p1, const Common::Point &p2, const Common::Point &delta, const WalkingPath& path);
const WalkingPath& getPath() const { return _path; }
private: