From 5b3526e58712bce866add853418314be33ea1c28 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 26 Jan 2018 07:51:42 -0500 Subject: XEEN: Implementing falling code --- engines/xeen/interface.cpp | 35 +++++++++++++++++++++++++---------- engines/xeen/interface.h | 15 ++++++++++++--- 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'engines/xeen') diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 5fec9ad08c..a46883b028 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -39,6 +39,10 @@ namespace Xeen { +enum { + SCENE_WINDOW = 11 +}; + PartyDrawer::PartyDrawer(XeenEngine *vm): _vm(vm) { _restoreSprites.load("restorex.icn"); _hpSprites.load("hpbars.icn"); @@ -1220,7 +1224,7 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) { Windows &windows = *_vm->_windows; events.timeMark5(); - if (windows[11]._enabled) + if (windows[SCENE_WINDOW]._enabled) return; _flipUIFrame = (_flipUIFrame + 1) % 4; @@ -1245,7 +1249,7 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) { handleFalling(); if (_falling == FALL_START) { - screen.saveBackground(1); + setupFallSurface(true); } assembleBorder(); @@ -1280,10 +1284,12 @@ void Interface::handleFalling() { Sound &sound = *_vm->_sound; Windows &windows = *_vm->_windows; Window &w = windows[3]; - saveFall(); + + Graphics::ManagedSurface savedBg; + setupFallSurface(false); for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - party._activeParty[idx]._faceSprites->draw(windows[0], 4, + party._activeParty[idx]._faceSprites->draw(0, 4, Common::Point(Res.CHAR_FACES_X[idx], 150)); } @@ -1322,14 +1328,23 @@ void Interface::handleFalling() { w.update(); shake(10); + + _falling = FALL_NONE; + drawParty(true); } -void Interface::saveFall() { - // TODO +void Interface::setupFallSurface(bool isTop) { + Window &w = (*g_vm->_windows)[SCENE_WINDOW]; + const Common::Rect &r = w.getBounds(); + + if (_fallSurface.empty()) + _fallSurface.create(r.width(), r.height() * 2); + _fallSurface.blitFrom(w, Common::Point(0, isTop ? 0 : r.height())); } -void Interface::fall(int v) { - // TODO +void Interface::fall(int yp) { + Window &w = (*g_vm->_windows)[SCENE_WINDOW]; + w.blitFrom(_fallSurface, Common::Rect(0, yp, _fallSurface.w, yp + (_fallSurface.h / 2)), Common::Point(0, 0)); } void Interface::shake(int time) { @@ -1861,11 +1876,11 @@ void Interface::spellFX(Character *c) { _spellFxSprites.draw(0, frameNum, Common::Point( Res.CHAR_FACES_X[charIndex], 150)); - if (!windows[11]._enabled) + if (!windows[SCENE_WINDOW]._enabled) draw3d(false); windows[0].update(); - events.wait(windows[11]._enabled ? 2 : 1,false); + events.wait(windows[SCENE_WINDOW]._enabled ? 2 : 1,false); } drawParty(true); diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 9e6a2a7555..321fe520c7 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -92,7 +92,7 @@ private: SpriteResource _blessSprites; SpriteResource _stdIcons; SpriteResource _combatIcons; - + Graphics::ManagedSurface _fallSurface; bool _buttonsLoaded; int _steppingFX; int _blessedUIFrame; @@ -129,9 +129,18 @@ private: */ void handleFalling(); - void saveFall(); + /** + * Sets up a passed surface with a double height combination of the previously + * saved scene background and the newly rendered (but not displayed) scene + * below it. This will be used by the fall sequence to vertically shift from the + * prior "upper" scene to the lower ground scene + */ + void setupFallSurface(bool isTop); - void fall(int v); + /** + * Handles a frame of falling animation + */ + void fall(int yp); /** * Shake the screen -- cgit v1.2.3