aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/animation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/avalanche/animation.cpp')
-rw-r--r--engines/avalanche/animation.cpp149
1 files changed, 126 insertions, 23 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp
index ef30faa87c..451b4a1c68 100644
--- a/engines/avalanche/animation.cpp
+++ b/engines/avalanche/animation.cpp
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -48,6 +48,37 @@ const int32 Animation::kCatacombMap[8][8] = {
AnimationType::AnimationType(Animation *anim) {
_anim = anim;
+
+ _xLength = 0;
+ _yLength = 0;
+ for (int i = 0; i < 24; i++) {
+ _mani[i] = nullptr;
+ _sil[i] = nullptr;
+ }
+ _frameNum = 0;
+ _seq = 0;
+ _characterId = 0;
+ _count = 0;
+ _facingDir = kDirNone;
+ _stepNum = 0;
+ _x = 0;
+ _y = 0;
+ _moveX = 0;
+ _moveY = 0;
+ _quick = false;
+ _visible = false;
+ _homing = false;
+ _doCheck = false;
+ _homingX = 0;
+ _homingY = 0;
+ _speedX = 0;
+ _speedY = 0;
+ _vanishIfStill = false;
+ _callEachStepFl = false;
+ _eachStepProc = Animation::kProcNone;
+ _fgBubbleCol = kColorWhite;
+ _bgBubbleCol = kColorBlack;
+ _id = 177;
}
/**
@@ -217,7 +248,7 @@ void AnimationType::walk() {
break;
case kMagicUnfinished: {
bounce();
- Common::String tmpStr = Common::String::format("%c%cSorry.%cThis place is not available yet!",
+ Common::String tmpStr = Common::String::format("%c%cSorry.%cThis place is not available yet!",
kControlBell, kControlCenter, kControlRoman);
_anim->_vm->_dialogs->displayText(tmpStr);
}
@@ -370,6 +401,13 @@ Animation::Animation(AvalancheEngine *vm) {
for (int16 i = 0; i < kSpriteNumbMax; i++) {
_sprites[i] = new AnimationType(this);
}
+
+ _direction = kDirNone;
+ _oldDirection = kDirNone;
+ _arrowTriggered = false;
+ _geidaSpin = 0;
+ _geidaTime = 0;
+ _sayWhat = 0;
}
Animation::~Animation() {
@@ -726,7 +764,7 @@ void Animation::catacombMove(byte ped) {
spr1->init(5, true); // ...Load Geida.
appearPed(1, geidaPed(ped));
spr1->_callEachStepFl = true;
- spr1->_eachStepProc = kProcGeida;
+ spr1->_eachStepProc = kProcFollowAvvy;
}
}
@@ -754,7 +792,7 @@ void Animation::callSpecial(uint16 which) {
_vm->_magics[11]._data = 5;
_vm->_magics[3]._operation = kMagicBounce; // Now works as planned!
stopWalking();
- _vm->_dialogs->displayScrollChain('q', 26);
+ _vm->_dialogs->displayScrollChain('Q', 26);
_vm->_userMovesAvvy = true;
break;
case 3: // _vm->special 3: Room 71: triggers dart.
@@ -777,22 +815,20 @@ void Animation::callSpecial(uint16 which) {
}
break;
case 4: // This is the ghost room link.
- _vm->fadeOut();
- _sprites[0]->turn(kDirRight); // you'll see this after we get back from bootstrap
+ _sprites[0]->turn(kDirRight); // You'll see this after we get back.
_vm->_timer->addTimer(1, Timer::kProcGhostRoomPhew, Timer::kReasonGhostRoomPhew);
- //_vm->_enid->backToBootstrap(3); TODO: Replace it with proper ScummVM-friendly function(s)! Do not remove until then!
+ _vm->_ghostroom->run();
break;
case 5:
if (_vm->_friarWillTieYouUp) {
// _vm->special 5: Room 42: touched tree, and get tied up.
_vm->_magics[4]._operation = kMagicBounce; // Boundary effect is now working again.
- _vm->_dialogs->displayScrollChain('q', 35);
+ _vm->_dialogs->displayScrollChain('Q', 35);
_sprites[0]->remove();
- //tr[1].vanishifstill:=true;
AnimationType *spr1 = _sprites[1];
_vm->_background->draw(-1, -1, 1);
- _vm->_dialogs->displayScrollChain('q', 36);
+ _vm->_dialogs->displayScrollChain('Q', 36);
_vm->_tiedUp = true;
_vm->_friarWillTieYouUp = false;
spr1->walkTo(2);
@@ -825,7 +861,7 @@ void Animation::callSpecial(uint16 which) {
case 8: // _vm->special 8: leave du Lustie's room.
if (_vm->_geidaFollows && !_vm->_lustieIsAsleep) {
AnimationType *spr1 = _sprites[1];
- _vm->_dialogs->displayScrollChain('q', 63);
+ _vm->_dialogs->displayScrollChain('Q', 63);
spr1->turn(kDirDown);
spr1->stopWalk();
spr1->_callEachStepFl = false; // Geida
@@ -848,9 +884,9 @@ void Animation::callSpecial(uint16 which) {
if ((_vm->_catacombX == 4) && (_vm->_catacombY == 1)) {
// Into Geida's room.
if (_vm->_objects[kObjectKey - 1])
- _vm->_dialogs->displayScrollChain('q', 62);
+ _vm->_dialogs->displayScrollChain('Q', 62);
else {
- _vm->_dialogs->displayScrollChain('q', 61);
+ _vm->_dialogs->displayScrollChain('Q', 61);
return;
}
}
@@ -1031,7 +1067,7 @@ void Animation::arrowProcs(byte tripnum) {
void Animation::grabAvvy(byte tripnum) { // For Friar Tuck, in Nottingham.
AnimationType *tripSpr = _sprites[tripnum];
- AnimationType *avvy = _sprites[tripnum];
+ AnimationType *avvy = _sprites[0];
int16 tox = avvy->_x + 17;
int16 toy = avvy->_y - 1;
@@ -1085,7 +1121,7 @@ void Animation::spin(Direction dir, byte &tripnum) {
}
}
-void Animation::geidaProcs(byte tripnum) {
+void Animation::follow(byte tripnum) {
AnimationType *tripSpr = _sprites[tripnum];
AnimationType *avvy = _sprites[0];
@@ -1096,14 +1132,14 @@ void Animation::geidaProcs(byte tripnum) {
}
if (tripSpr->_y < (avvy->_y - 2)) {
- // Geida is further from the screen than Avvy.
+ // The following NPC is further from the screen than Avvy.
spin(kDirDown, tripnum);
tripSpr->_moveY = 1;
tripSpr->_moveX = 0;
takeAStep(tripnum);
return;
} else if (tripSpr->_y > (avvy->_y + 2)) {
- // Avvy is further from the screen than Geida.
+ // Avvy is further from the screen than the following NPC.
spin(kDirUp, tripnum);
tripSpr->_moveY = -1;
tripSpr->_moveX = 0;
@@ -1169,8 +1205,9 @@ void Animation::drawSprites() {
* @remarks Originally called 'trippancy_link'
*/
void Animation::animLink() {
- if (_vm->_menu->isActive() || _vm->_seeScroll)
+ if (_vm->_dropdown->isActive() || !_vm->_animationsEnabled)
return;
+
for (int16 i = 0; i < kSpriteNumbMax; i++) {
AnimationType *curSpr = _sprites[i];
if (curSpr->_quick && curSpr->_visible)
@@ -1199,8 +1236,10 @@ void Animation::animLink() {
case kProcGrabAvvy :
grabAvvy(i);
break;
- case kProcGeida :
- geidaProcs(i);
+ case kProcFollowAvvy :
+ follow(i);
+ break;
+ default:
break;
}
}
@@ -1208,7 +1247,7 @@ void Animation::animLink() {
if (_mustExclaim) {
_mustExclaim = false;
- _vm->_dialogs->displayScrollChain('x', _sayWhat);
+ _vm->_dialogs->displayScrollChain('X', _sayWhat);
}
}
@@ -1291,7 +1330,7 @@ void Animation::handleMoveKey(const Common::Event &event) {
if (!_vm->_userMovesAvvy)
return;
- if (_vm->_menu->_activeMenuItem._activeNow)
+ if (_vm->_dropdown->_activeMenuItem._activeNow)
_vm->_parser->tryDropdown();
else {
switch (event.kbd.keycode) {
@@ -1360,6 +1399,69 @@ void Animation::handleMoveKey(const Common::Event &event) {
}
}
+/**
+* Draws a part of the lightning bolt for thunder().
+* @remarks Originally called 'zl'
+*/
+void Animation::drawLightning(int16 x1, int16 y1, int16 x2, int16 y2) {
+ _vm->_graphics->drawLine(x1, y1 - 1, x2, y2 - 1, 1, 3, kColorBlue);
+ _vm->_graphics->drawLine(x1, y1, x2, y2, 1, 1, kColorLightcyan);
+}
+
+/**
+* Plays the actual thunder animation when Avvy (the player) swears too much.
+* @remarks Originally called 'zonk'
+*/
+void Animation::thunder() {
+ _vm->_graphics->setBackgroundColor(kColorYellow);
+
+ _vm->_graphics->saveScreen();
+
+ int x = _vm->_animation->_sprites[0]->_x + _vm->_animation->_sprites[0]->_xLength / 2;
+ int y = _vm->_animation->_sprites[0]->_y;
+
+ for (int i = 0; i < 256; i++) {
+ _vm->_sound->playNote(270 - i, 1);
+
+ drawLightning(640, 0, 0, y / 4);
+ drawLightning(0, y / 4, 640, y / 2);
+ drawLightning(640, y / 2, x, y);
+ _vm->_graphics->refreshScreen();
+
+ _vm->_sound->playNote(2700 - 10 * i, 5);
+ _vm->_system->delayMillis(5);
+ _vm->_sound->playNote(270 - i, 1);
+
+ _vm->_graphics->restoreScreen();
+ _vm->_sound->playNote(2700 - 10 * i, 5);
+ _vm->_system->delayMillis(5);
+ }
+
+ _vm->_graphics->restoreScreen();
+ _vm->_graphics->removeBackup();
+
+ _vm->_graphics->setBackgroundColor(kColorBlack);
+}
+
+/**
+* Makes the screen wobble.
+*/
+void Animation::wobble() {
+ _vm->_graphics->saveScreen();
+
+ for (int i = 0; i < 26; i++) {
+ _vm->_graphics->shiftScreen();
+ _vm->_graphics->refreshScreen();
+ _vm->_system->delayMillis(i * 7);
+
+ _vm->_graphics->restoreScreen();
+ _vm->_system->delayMillis(i * 7);
+ }
+
+ _vm->_graphics->restoreScreen();
+ _vm->_graphics->removeBackup();
+}
+
void Animation::setDirection(Direction dir) {
_direction = dir;
}
@@ -1394,6 +1496,7 @@ int Animation::getAvvyClothes() {
}
void Animation::resetVariables() {
+ setDirection(kDirUp);
_geidaSpin = 0;
_geidaTime = 0;
_arrowTriggered = false;