aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/scalpel/scalpel_people.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-11 22:02:33 -0400
committerPaul Gilbert2015-06-11 22:02:33 -0400
commit3d0e2cb5b000bfa9ff731fc6a83ec402bd9f7aad (patch)
treef3780949461d600f733e33cea286f425d5f80619 /engines/sherlock/scalpel/scalpel_people.cpp
parentf812447274fc1de46560e4e611c9d4cb9bf39beb (diff)
downloadscummvm-rg350-3d0e2cb5b000bfa9ff731fc6a83ec402bd9f7aad.tar.gz
scummvm-rg350-3d0e2cb5b000bfa9ff731fc6a83ec402bd9f7aad.tar.bz2
scummvm-rg350-3d0e2cb5b000bfa9ff731fc6a83ec402bd9f7aad.zip
SHERLOCK: Beginning of descendent Person classes
Tattoo has some different Sprite methods, and since Person descends from Sprite, need to create descendents from it. And this has also necessitated some refactoring of People class's _data array
Diffstat (limited to 'engines/sherlock/scalpel/scalpel_people.cpp')
-rw-r--r--engines/sherlock/scalpel/scalpel_people.cpp121
1 files changed, 114 insertions, 7 deletions
diff --git a/engines/sherlock/scalpel/scalpel_people.cpp b/engines/sherlock/scalpel/scalpel_people.cpp
index 80e6061e8b..e0abd72842 100644
--- a/engines/sherlock/scalpel/scalpel_people.cpp
+++ b/engines/sherlock/scalpel/scalpel_people.cpp
@@ -28,6 +28,113 @@ namespace Sherlock {
namespace Scalpel {
+void ScalpelPerson::adjustSprite() {
+ Map &map = *_vm->_map;
+ People &people = *_vm->_people;
+ Scene &scene = *_vm->_scene;
+ Talk &talk = *_vm->_talk;
+
+ if (_type == INVALID || (_type == CHARACTER && scene._animating))
+ return;
+
+ if (!talk._talkCounter && _type == CHARACTER && _walkCount) {
+ // Handle active movement for the sprite
+ _position += _delta;
+ --_walkCount;
+
+ if (!_walkCount) {
+ // If there any points left for the character to walk to along the
+ // route to a destination, then move to the next point
+ if (!people._walkTo.empty()) {
+ people._walkDest = people._walkTo.pop();
+ people.setWalking();
+ } else {
+ people.gotoStand(*this);
+ }
+ }
+ }
+
+ if (_type == CHARACTER && !map._active) {
+ if ((_position.y / FIXED_INT_MULTIPLIER) > LOWER_LIMIT) {
+ _position.y = LOWER_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.y / FIXED_INT_MULTIPLIER) < UPPER_LIMIT) {
+ _position.y = UPPER_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.x / FIXED_INT_MULTIPLIER) < LEFT_LIMIT) {
+ _position.x = LEFT_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+
+ if ((_position.x / FIXED_INT_MULTIPLIER) > RIGHT_LIMIT) {
+ _position.x = RIGHT_LIMIT * FIXED_INT_MULTIPLIER;
+ people.gotoStand(*this);
+ }
+ } else if (!map._active) {
+ _position.y = CLIP((int)_position.y, (int)UPPER_LIMIT, (int)LOWER_LIMIT);
+ _position.x = CLIP((int)_position.x, (int)LEFT_LIMIT, (int)RIGHT_LIMIT);
+ }
+
+ if (!map._active || (map._frameChangeFlag = !map._frameChangeFlag))
+ ++_frameNumber;
+
+ if (_frameNumber >= (int)_walkSequences[_sequenceNumber]._sequences.size() ||
+ _walkSequences[_sequenceNumber][_frameNumber] == 0) {
+ switch (_sequenceNumber) {
+ case Scalpel::STOP_UP:
+ case Scalpel::STOP_DOWN:
+ case Scalpel::STOP_LEFT:
+ case Scalpel::STOP_RIGHT:
+ case Scalpel::STOP_UPRIGHT:
+ case Scalpel::STOP_UPLEFT:
+ case Scalpel::STOP_DOWNRIGHT:
+ case Scalpel::STOP_DOWNLEFT:
+ // We're in a stop sequence, so reset back to the last frame, so
+ // the character is shown as standing still
+ --_frameNumber;
+ break;
+
+ default:
+ // Move 1 past the first frame - we need to compensate, since we
+ // already passed the frame increment
+ _frameNumber = 1;
+ break;
+ }
+ }
+
+ // Update the _imageFrame to point to the new frame's image
+ setImageFrame();
+
+ // Check to see if character has entered an exit zone
+ if (!_walkCount && scene._walkedInScene && scene._goToScene == -1) {
+ Common::Rect charRect(_position.x / FIXED_INT_MULTIPLIER - 5, _position.y / FIXED_INT_MULTIPLIER - 2,
+ _position.x / FIXED_INT_MULTIPLIER + 5, _position.y / FIXED_INT_MULTIPLIER + 2);
+ Exit *exit = scene.checkForExit(charRect);
+
+ if (exit) {
+ scene._goToScene = exit->_scene;
+
+ if (exit->_people.x != 0) {
+ people._hSavedPos = exit->_people;
+ people._hSavedFacing = exit->_peopleDir;
+
+ if (people._hSavedFacing > 100 && people._hSavedPos.x < 1)
+ people._hSavedPos.x = 100;
+ }
+ }
+ }
+}
+
+/*----------------------------------------------------------------*/
+
+ScalpelPeople::ScalpelPeople(SherlockEngine *vm) : People(vm) {
+ _data.push_back(new ScalpelPerson());
+}
+
void ScalpelPeople::setTalking(int speaker) {
Resources &res = *_vm->_res;
@@ -89,14 +196,14 @@ void ScalpelPeople::setTalking(int speaker) {
void ScalpelPeople::synchronize(Serializer &s) {
s.syncAsByte(_holmesOn);
- s.syncAsSint32LE(_player._position.x);
- s.syncAsSint32LE(_player._position.y);
- s.syncAsSint16LE(_player._sequenceNumber);
+ s.syncAsSint32LE(_data[PLAYER]->_position.x);
+ s.syncAsSint32LE(_data[PLAYER]->_position.y);
+ s.syncAsSint16LE(_data[PLAYER]->_sequenceNumber);
s.syncAsSint16LE(_holmesQuotient);
if (s.isLoading()) {
- _hSavedPos = _player._position;
- _hSavedFacing = _player._sequenceNumber;
+ _hSavedPos = _data[PLAYER]->_position;
+ _hSavedFacing = _data[PLAYER]->_sequenceNumber;
}
}
@@ -172,8 +279,8 @@ void ScalpelPeople::gotoStand(Sprite &sprite) {
if (map._active) {
sprite._sequenceNumber = 0;
- _player._position.x = (map[map._charPoint].x - 6) * FIXED_INT_MULTIPLIER;
- _player._position.y = (map[map._charPoint].y + 10) * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_position.x = (map[map._charPoint].x - 6) * FIXED_INT_MULTIPLIER;
+ _data[PLAYER]->_position.y = (map[map._charPoint].y + 10) * FIXED_INT_MULTIPLIER;
}
_oldWalkSequence = -1;