diff options
author | Eugene Sandulenko | 2014-01-04 01:02:12 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2014-01-04 01:02:12 +0200 |
commit | 5b2acd514f5c8f83efdb61e84805d785bef0a9d2 (patch) | |
tree | 99657a1e79a129771157b6af9903e0afea88300e /engines | |
parent | 6854decc0089dc42a69600cf826cc1d323b8681b (diff) | |
download | scummvm-rg350-5b2acd514f5c8f83efdb61e84805d785bef0a9d2.tar.gz scummvm-rg350-5b2acd514f5c8f83efdb61e84805d785bef0a9d2.tar.bz2 scummvm-rg350-5b2acd514f5c8f83efdb61e84805d785bef0a9d2.zip |
FULLPIPE: Implement Floaters::update()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/constants.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/floaters.cpp | 111 | ||||
-rw-r--r-- | engines/fullpipe/motion.cpp | 38 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 6 |
4 files changed, 154 insertions, 2 deletions
diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h index 73fa3b03a3..d75aa3d363 100644 --- a/engines/fullpipe/constants.h +++ b/engines/fullpipe/constants.h @@ -29,6 +29,7 @@ namespace Fullpipe { #define ANI_FLY 4916 #define MV_FLY_FLY 4917 #define SND_CMN_060 4921 +#define SND_CMN_061 4922 #define ST_FLY_FLY 4918 #define ANI_BALLDROP 2685 diff --git a/engines/fullpipe/floaters.cpp b/engines/fullpipe/floaters.cpp index 1a9e52c580..b405e331ff 100644 --- a/engines/fullpipe/floaters.cpp +++ b/engines/fullpipe/floaters.cpp @@ -123,7 +123,116 @@ void Floaters::genFlies(Scene *sc, int x, int y, int priority, int flags) { } void Floaters::update() { - warning("STUB: Floaters::update()"); + for (int i = 0; i < _array2.size(); ++i) { + if (_array2[i]->val13 <= 0) { + if (_array2[i]->val4 != _array2[i]->val2 || _array2[i]->val5 != _array2[i]->val3) { + if (_array2[i]->val9 < 2.0) + _array2[i]->val9 = 2.0; + + int dy = _array2[i]->val3 - _array2[i]->val5; + int dx = _array2[i]->val2 - _array2[i]->val4; + double dst = sqrt((double)(dy * dy + dx * dx)); + double at = atan2((double)dx, (double)dy); + int newX = (int)(cos(at) * _array2[i]->val9); + int newY = (int)(sin(at) * _array2[i]->val9); + + if (dst < _array2[i]->val9) { + newX = _array2[i]->val2 - _array2[i]->val4; + newY = _array2[i]->val3 - _array2[i]->val5; + } + if (dst <= 30.0) { + if (dst < 30.0) { + _array2[i]->val9 = _array2[i]->val9 - _array2[i]->val9 * 0.5; + + if (_array2[i]->val9 < 2.0) + _array2[i]->val9 = 2.0; + } + } else { + _array2[i]->val9 = _array2[i]->val9 * 0.5 + _array2[i]->val9; + + if (_array2[i]->val9 > _array2[i]->val11) + _array2[i]->val9 = _array2[i]->val11; + } + + _array2[i]->val4 += newX; + _array2[i]->val5 += newY; + _array2[i]->ani->setOXY(newX + _array2[i]->ani->_ox, newY + _array2[i]->ani->_oy); + + if (_array2[i]->val4 == _array2[i]->val2 && _array2[i]->val5 == _array2[i]->val3) { + _array2[i]->val9 = 0.0; + + _array2[i]->val13 = g_fp->_rnd->getRandomNumber(200) + 20; + + if (_array2[i]->fflags & 1) { + g_fp->_currentScene->deleteStaticANIObject(_array2[i]->ani); + + if (_array2[i]->ani) + delete _array2[i]->ani; + + _array2.remove_at(i); + + i--; + + if (!_array2.size()) + g_fp->stopAllSoundInstances(SND_CMN_060); + + continue; + } + } + } else { + if ((_array2[i]->fflags & 4) && _array2[i]->countdown < 1) { + _array2[i]->fflags |= 1; + _array2[i]->val2 = _array2[i]->val6; + _array2[i]->val3 = _array2[i]->val7; + } else { + if (_array2[i]->fflags & 2) { + int idx1 = g_fp->_rnd->getRandomNumber(_array1.size()); + + _array2[i]->val2 = _array1[idx1]->val1; + _array2[i]->val3 = _array1[idx1]->val2; + } else { + Common::Rect rect; + + if (!_hRgn) + error("Floaters::update(): empty fliers region"); + + _hRgn->getBBox(&rect); + + int x2 = rect.left + g_fp->_rnd->getRandomNumber(rect.right - rect.left); + int y2 = rect.top + g_fp->_rnd->getRandomNumber(rect.bottom - rect.top); + + if (_hRgn->pointInRegion(x2, y2)) { + int dx = _array2[i]->val2 - x2; + int dy = _array2[i]->val3 - y2; + double dst = sqrt((double)(dy * dy + dx * dx)); + + if (dst < 300.0 || !_hRgn->pointInRegion(_array2[i]->val4, _array2[i]->val5)) { + _array2[i]->val2 = x2; + _array2[i]->val3 = y2; + } + } + } + + g_fp->playSound(SND_CMN_061, 0); + + if (_array2[i]->fflags & 4) + _array2[i]->countdown--; + } + } + } else { + _array2[i]->val13--; + } + + if (!_array2[i]->ani->_movement && _array2[i]->ani->_statics->_staticsId == ST_FLY_FLY) { + if (!_array2[i]->val15) { + g_fp->playSound(SND_CMN_060, 1); + + _array2[i]->val15 = 1; + } + + _array2[i]->ani->startAnim(MV_FLY_FLY, 0, -1); + } + } } void Floaters::stopAll() { diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 069679430f..6e4c1b69e7 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -2037,6 +2037,11 @@ void ReactParallel::setCenter(int x1, int y1, int x2, int y2) { ReactPolygonal::ReactPolygonal() { _centerX = 0; _centerY = 0; + _bbox = 0; +} + +ReactPolygonal::~ReactPolygonal() { + delete _bbox; } bool ReactPolygonal::load(MfcArchive &file) { @@ -2085,6 +2090,39 @@ void ReactPolygonal::setCenter(int x1, int y1, int x2, int y2) { _centerY = cY; } +void ReactPolygonal::getBBox(Common::Rect *rect) { + if (!_pointCount) + return; + + if (_bbox) { + *rect = *_bbox; + return; + } + + rect->left = _points[0]->x; + rect->top = _points[0]->y; + rect->right = _points[0]->x; + rect->bottom = _points[0]->y; + + for (int i = 1; i < _pointCount; i++) { + if (rect->left > _points[i]->x) + rect->left = _points[i]->x; + + if (rect->top < _points[i]->y) + rect->top = _points[i]->y; + + if (rect->right < _points[i]->x) + rect->right = _points[i]->x; + + if (rect->bottom > _points[i]->y) + rect->bottom = _points[i]->y; + } + + _bbox = new Common::Rect; + *_bbox = *rect; +} + + bool MovGraphReact::pointInRegion(int x, int y) { if (_pointCount < 3) { return false; diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 6ca24a303f..1e813eec57 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -253,16 +253,20 @@ public: }; class ReactPolygonal : public MovGraphReact { - //CRgn _rgn; + Common::Rect *_bbox; int _centerX; int _centerY; public: ReactPolygonal(); + ~ReactPolygonal(); + virtual bool load(MfcArchive &file); virtual void setCenter(int x1, int y1, int x2, int y2); virtual void createRegion(); + + void getBBox(Common::Rect *rect); }; class MovGraphLink : public CObject { |