aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo/object_v1d.cpp
diff options
context:
space:
mode:
authorArnaud Boutonné2011-01-19 00:49:49 +0000
committerArnaud Boutonné2011-01-19 00:49:49 +0000
commit3ba7a21c622f63bfbebe39279a4f40507e74f7f4 (patch)
tree87e882b6d4d78a4ac7500ac412053fde3c8f80c5 /engines/hugo/object_v1d.cpp
parent22c3e7b1de17403e246e2a0f8a1e238de0cc9310 (diff)
downloadscummvm-rg350-3ba7a21c622f63bfbebe39279a4f40507e74f7f4.tar.gz
scummvm-rg350-3ba7a21c622f63bfbebe39279a4f40507e74f7f4.tar.bz2
scummvm-rg350-3ba7a21c622f63bfbebe39279a4f40507e74f7f4.zip
HUGO: Merge the 2 versions of doAction, cleanup
svn-id: r55318
Diffstat (limited to 'engines/hugo/object_v1d.cpp')
-rw-r--r--engines/hugo/object_v1d.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp
index 76b114f354..6eb44fcaa0 100644
--- a/engines/hugo/object_v1d.cpp
+++ b/engines/hugo/object_v1d.cpp
@@ -228,7 +228,7 @@ void ObjectHandler_v1d::moveObjects() {
obj->cycling = CYCLE_FORWARD;
} else {
obj->cycling = NOT_CYCLING;
- _vm->boundaryCollision(obj); // Must have got hero!
+ _vm->boundaryCollision(obj); // Must have got hero!
}
dxOld = obj->vx;
currImage = obj->currImagePtr; // Get (new) ptr to current image
@@ -275,7 +275,7 @@ void ObjectHandler_v1d::moveObjects() {
// Move objects, allowing for boundaries
for (int i = 0; i < _numObj; i++) {
- object_t *obj = &_objects[i]; // Get pointer to object
+ object_t *obj = &_objects[i]; // Get pointer to object
if ((obj->screenIndex == *_vm->_screen_p) && (obj->vx || obj->vy)) {
// Only process if it's moving
@@ -289,7 +289,7 @@ void ObjectHandler_v1d::moveObjects() {
int y2 = obj->y + currImage->y2; // Bottom edge
if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
- _vm->clearBoundary(x1, x2, y2); // Clear our own boundary
+ _vm->clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary
int dx = _vm->deltaX(x1, x2, obj->vx, y2);
@@ -307,7 +307,7 @@ void ObjectHandler_v1d::moveObjects() {
}
if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
- _vm->storeBoundary(x1, x2, y2); // Re-store our own boundary
+ _vm->storeBoundary(x1, x2, y2); // Re-store our own boundary
obj->x += dx; // Update object position
obj->y += dy;
@@ -337,12 +337,12 @@ void ObjectHandler_v1d::moveObjects() {
// If maze mode is enabled, do special maze processing
if (_maze.enabledFl) {
- seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image
+ seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image
// hero coordinates
- int x1 = _vm->_hero->x + currImage->x1; // Left edge of object
- int x2 = _vm->_hero->x + currImage->x2; // Right edge
- int y1 = _vm->_hero->y + currImage->y1; // Top edge
- int y2 = _vm->_hero->y + currImage->y2; // Bottom edge
+ int x1 = _vm->_hero->x + currImage->x1; // Left edge of object
+ int x2 = _vm->_hero->x + currImage->x2; // Right edge
+ int y1 = _vm->_hero->y + currImage->y1; // Top edge
+ int y2 = _vm->_hero->y + currImage->y2; // Bottom edge
_vm->_scheduler->processMaze(x1, x2, y1, y2);
}
@@ -367,4 +367,25 @@ void ObjectHandler_v1d::swapImages(int objIndex1, int objIndex2) {
_vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO;
}
+void ObjectHandler_v1d::homeIn(int objIndex1, int objIndex2, int8 objDx, int8 objDy) {
+ // object obj1 will home in on object obj2
+ object_t *obj1 = &_objects[objIndex1];
+ object_t *obj2 = &_objects[objIndex2];
+ obj1->pathType = AUTO;
+ int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1;
+ int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1;
+
+ if (dx == 0) // Don't EVER divide by zero!
+ dx = 1;
+ if (dy == 0)
+ dy = 1;
+
+ if (abs(dx) > abs(dy)) {
+ obj1->vx = objDx * -SIGN(dx);
+ obj1->vy = abs((objDy * dy) / dx) * -SIGN(dy);
+ } else {
+ obj1->vy = objDy * SIGN(dy);
+ obj1->vx = abs((objDx * dx) / dy) * SIGN(dx);
+ }
+}
} // End of namespace Hugo