From de4ec97f6dbb1b97ef8c9eda453f51dbd318cafe Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 15 Jan 2014 20:03:06 +0100 Subject: AVALANCHE: Implement wobble, move it to Animation. --- engines/avalanche/animation.cpp | 19 +++++++++++++++++++ engines/avalanche/animation.h | 2 ++ engines/avalanche/graphics.cpp | 10 ++++++++++ engines/avalanche/graphics.h | 3 +++ engines/avalanche/parser.cpp | 2 +- engines/avalanche/pingo.cpp | 4 ---- engines/avalanche/pingo.h | 1 - engines/avalanche/timer.cpp | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp index 9f9822eaa0..639abe99b3 100644 --- a/engines/avalanche/animation.cpp +++ b/engines/avalanche/animation.cpp @@ -1443,6 +1443,25 @@ void Animation::thunder() { _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; } diff --git a/engines/avalanche/animation.h b/engines/avalanche/animation.h index d3b52c704d..aa4e6482a4 100644 --- a/engines/avalanche/animation.h +++ b/engines/avalanche/animation.h @@ -129,6 +129,8 @@ public: void drawLightning(int16 x1, int16 y1, int16 x2, int16 y2); void thunder(); + void wobble(); + void setDirection(Direction dir); void setOldDirection(Direction dir); Direction getDirection(); diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index fec483b933..82248f5087 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -577,6 +577,16 @@ Graphics::Surface GraphicManager::loadPictureSign(Common::File &file, int xl, in return picture; } +/** +* Shifts the whole screen down by one line and fills the gap with black. +*/ +void GraphicManager::shiftScreen() { + for (uint16 y = _surface.h - 1; y > 1; y--) + memcpy(_surface.getBasePtr(0, y), _surface.getBasePtr(0, y - 1), _surface.w); + + _surface.drawLine(0, 0, _surface.w, 0, kColorBlack); +} + void GraphicManager::clearAlso() { _magics.fillRect(Common::Rect(0, 0, 640, 200), 0); _magics.frameRect(Common::Rect(0, 45, 640, 161), 15); diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 4c811e5378..ea3b621d69 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -87,6 +87,9 @@ public: void nimDrawLogo(); void nimFree(); + // Used in wobble() + void shiftScreen(); + void clearAlso(); void clearTextBar(); void setAlsoLine(int x1, int y1, int x2, int y2, Color color); diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 362c818ed1..34cdb95a55 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -1144,7 +1144,7 @@ void Parser::swallow() { return; } _vm->_dialogs->displayScrollChain('U', 1); - _vm->_pingo->wobble(); + _vm->_animation->wobble(); _vm->_dialogs->displayScrollChain('U', 2); _vm->_objects[kObjectWine - 1] = false; _vm->refreshObjectList(); diff --git a/engines/avalanche/pingo.cpp b/engines/avalanche/pingo.cpp index d8550f9275..40467ab839 100644 --- a/engines/avalanche/pingo.cpp +++ b/engines/avalanche/pingo.cpp @@ -56,10 +56,6 @@ void Pingo::copyPage(byte frp, byte top) { // taken from Copy02 (above) warning("STUB: Pingo::copyPage()"); } -void Pingo::wobble() { - warning("STUB: Pingo::wobble()"); -} - void Pingo::winningPic() { Common::File f; _vm->fadeOut(); diff --git a/engines/avalanche/pingo.h b/engines/avalanche/pingo.h index e3a516c04c..6eecaf6453 100644 --- a/engines/avalanche/pingo.h +++ b/engines/avalanche/pingo.h @@ -43,7 +43,6 @@ public: void copy02(); void copy03(); void copyPage(byte frp, byte top); - void wobble(); void winningPic(); private: diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp index 40f2af529a..c8ea820c0e 100644 --- a/engines/avalanche/timer.cpp +++ b/engines/avalanche/timer.cpp @@ -492,7 +492,7 @@ void Timer::buyDrinks() { _vm->_malagauche = 0; _vm->_dialogs->displayScrollChain('D', _vm->_drinking); // Display message about it. - _vm->_pingo->wobble(); // Do the special effects. + _vm->_animation->wobble(); // Do the special effects. _vm->_dialogs->displayScrollChain('D', 1); // That'll be thruppence. if (_vm->decreaseMoney(3)) // Pay 3d. _vm->_dialogs->displayScrollChain('D', 3); // Tell 'em you paid up. -- cgit v1.2.3