aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parallaction.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2008-07-26 04:01:11 +0000
committerNicola Mettifogo2008-07-26 04:01:11 +0000
commit7950a9183b34fe60f979576c6f4d5b6f9d56a3dc (patch)
treeb944447d67c72ceb375e3c3d8ec09d5432b9c064 /engines/parallaction/parallaction.cpp
parentaee128467893daa3e3482ad3c9a90b66cbc1bcdf (diff)
downloadscummvm-rg350-7950a9183b34fe60f979576c6f4d5b6f9d56a3dc.tar.gz
scummvm-rg350-7950a9183b34fe60f979576c6f4d5b6f9d56a3dc.tar.bz2
scummvm-rg350-7950a9183b34fe60f979576c6f4d5b6f9d56a3dc.zip
* Added walk calculations to BRA (doesn't walk yet, though).
* Adapted Character and Animation to handle both versions of the engine. svn-id: r33296
Diffstat (limited to 'engines/parallaction/parallaction.cpp')
-rw-r--r--engines/parallaction/parallaction.cpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index b5f2de851b..78e7af6343 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -497,7 +497,7 @@ const char Character::_suffixTras[] = "tras";
const char Character::_empty[] = "\0";
-Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation), _builder(_ani) {
+Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) {
_talk = NULL;
_head = NULL;
_objs = NULL;
@@ -516,25 +516,63 @@ Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation), _builder(
_ani->_flags = kFlagsActive | kFlagsNoName;
_ani->_type = kZoneYou;
strncpy(_ani->_name, "yourself", ZONENAME_LENGTH);
+
+ // TODO: move creation into Parallaction. Needs to make Character a pointer first.
+ if (_vm->getGameType() == GType_Nippon)
+ _builder = new PathBuilder_NS(this);
+ else
+ _builder = new PathBuilder_BR(this);
+}
+
+Character::~Character() {
+ delete _builder;
+ _builder = 0;
+
+ free();
}
void Character::getFoot(Common::Point &foot) {
- foot.x = _ani->_left + _ani->width() / 2;
- foot.y = _ani->_top + _ani->height();
+ Common::Rect rect;
+ _ani->gfxobj->getRect(_ani->_frame, rect);
+
+ foot.x = _ani->_left + (rect.left + rect.width() / 2);
+ foot.y = _ani->_top + (rect.top + rect.height());
}
void Character::setFoot(const Common::Point &foot) {
- _ani->_left = foot.x - _ani->width() / 2;
- _ani->_top = foot.y - _ani->height();
+ Common::Rect rect;
+ _ani->gfxobj->getRect(_ani->_frame, rect);
+
+ _ani->_left = foot.x - (rect.left + rect.width() / 2);
+ _ani->_top = foot.y - (rect.top + rect.height());
}
+#if 0
+void dumpPath(PointList *list, const char* text) {
+ for (PointList::iterator it = list->begin(); it != list->end(); it++)
+ printf("node (%i, %i)\n", it->x, it->y);
+
+ return;
+}
+#endif
+
void Character::scheduleWalk(int16 x, int16 y) {
if ((_ani->_flags & kFlagsRemove) || (_ani->_flags & kFlagsActive) == 0) {
return;
}
- _walkPath = _builder.buildPath(x, y);
- _engineFlags |= kEngineWalking;
+ _walkPath = _builder->buildPath(x, y);
+#if 0
+ dumpPath(_walkPath, _name);
+#endif
+
+ if (_vm->getGameType() == GType_Nippon) {
+ _engineFlags |= kEngineWalking;
+ } else {
+ // BRA can't walk yet!
+ delete _walkPath;
+ _walkPath = 0;
+ }
}
void Character::free() {