diff options
author | Paul Gilbert | 2017-03-05 14:20:54 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-03-05 14:20:54 -0500 |
commit | 7e418108f63fdccaac097380d8375c44205fe755 (patch) | |
tree | 3cf12e57d2ab530e033bfe5b7692b94d4e92e2f1 /engines | |
parent | bfcfc54b049343938cec88684a2da4bbfde8453a (diff) | |
download | scummvm-rg350-7e418108f63fdccaac097380d8375c44205fe755.tar.gz scummvm-rg350-7e418108f63fdccaac097380d8375c44205fe755.tar.bz2 scummvm-rg350-7e418108f63fdccaac097380d8375c44205fe755.zip |
TITANIC: Added remaining CStarField methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/star_control/fvector.h | 20 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.h | 10 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.cpp | 96 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.h | 8 |
5 files changed, 103 insertions, 47 deletions
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h index 8e1ba47a3e..a54e94dda7 100644 --- a/engines/titanic/star_control/fvector.h +++ b/engines/titanic/star_control/fvector.h @@ -63,6 +63,26 @@ public: bool operator!=(const FVector &src) const { return !operator==(src); } + + FVector operator+(const FVector &delta) const { + return FVector(_x + delta._x, _y + delta._y, _z + delta._z); + } + + FVector operator-(const FVector &delta) const { + return FVector(_x - delta._x, _y - delta._y, _z - delta._z); + } + + void operator+=(const FVector &delta) { + _x += delta._x; + _y += delta._y; + _z += delta._z; + } + + void operator-=(const FVector &delta) { + _x -= delta._x; + _y -= delta._y; + _z -= delta._z; + } }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index 5501ab80cc..3a09be3e8a 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -23,6 +23,7 @@ #include "titanic/star_control/star_field.h" #include "titanic/star_control/surface_area.h" #include "titanic/star_control/star_control_sub12.h" +#include "titanic/titanic.h" namespace Titanic { @@ -211,8 +212,8 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, } void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) { - CSurfaceArea surfaceArea(surface); - // TODO + CSurfaceArea surfaceArea(surface); + _sub8.fn1(this, &surfaceArea, sub12); } void CStarField::fn7() { @@ -241,4 +242,15 @@ bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub1 } } +const CBaseStarEntry *CStarField::getRandomStar() const { + if (_data.empty()) + return nullptr; + + return getDataPtr(g_vm->getRandomNumber(_data.size() - 1)); +} + +const CBaseStarEntry *CStarField::getStar(int index) const { + return (index < 0 || index >= (int)_data.size()) ? nullptr : getDataPtr(index); +} + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index 4eb955d927..34f11719d3 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -117,6 +117,16 @@ public: */ bool mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub12, int flags, const Common::Point &pt); + + /** + * Gets a random star + */ + const CBaseStarEntry *getRandomStar() const; + + /** + * Gets a specified star + */ + const CBaseStarEntry *getStar(int index) const; }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp index e717206e55..836de0f5a4 100644 --- a/engines/titanic/star_control/star_view.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -282,7 +282,7 @@ void CStarView::fn3(bool fadeIn) { void CStarView::fn4() { FVector v1, v2; - randomizeVectors2(&v1, &v2); + randomizeVectors2(v1, v2); _sub12.setPosition(v1); _sub12.proc5(v2); } @@ -296,7 +296,25 @@ void CStarView::fn6() { } void CStarView::fn7() { - // TODO + const CBaseStarEntry *star = _starField->getRandomStar(); + if (star) { + FVector v1, v2; + randomizeVectors3(v1, v2); + v2 += star->_position; + _sub12.setPosition(v2); + _sub12.proc5(v1); + } +} + +void CStarView::fn19(int index) { + const CBaseStarEntry *star = _starField->getStar(index); + if (star) { + FVector v1, v2; + randomizeVectors3(v1, v2); + v1 += star->_position; + _sub12.setPosition(v1); + _sub12.proc5(v2); + } } void CStarView::fn8() { @@ -342,7 +360,7 @@ void CStarView::fn14() { void CStarView::setHasReference() { FVector v1, v2; - randomizeVectors1(&v1, &v2); + randomizeVectors1(v1, v2); _sub13.setPosition(v1); _sub13.fn11(v2); @@ -388,60 +406,56 @@ void CStarView::fn18(CStarControlSub12 *sub12) { } } -void CStarView::fn19(int v) { - // TODO -} - -void CStarView::randomizeVectors1(FVector *v1, FVector *v2) { - v1->_x = g_vm->getRandomFloat() * -4096.0 - 3072.0; - v1->_y = g_vm->getRandomFloat() * -4096.0 - 3072.0; - v1->_z = g_vm->getRandomFloat() * -4096.0 - 3072.0; +void CStarView::randomizeVectors1(FVector &v1, FVector &v2) { + v1._x = g_vm->getRandomFloat() * -4096.0 - 3072.0; + v1._y = g_vm->getRandomFloat() * -4096.0 - 3072.0; + v1._z = g_vm->getRandomFloat() * -4096.0 - 3072.0; double vx = g_vm->getRandomFloat() * 8192.0; double vy = g_vm->getRandomFloat() * 1024.0; - vx -= v1->_x; - vy -= v1->_y; + vx -= v1._x; + vy -= v1._y; - v2->_x = vx; - v2->_y = vy; - v2->_z = -v1->_z; - v2->fn3(); + v2._x = vx; + v2._y = vy; + v2._z = -v1._z; + v2.fn3(); } -void CStarView::randomizeVectors2(FVector *v1, FVector *v2) { - v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0; +void CStarView::randomizeVectors2(FVector &v1, FVector &v2) { + v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0; // TODO: Doublecheck - v2->_x = -v1->_x; - v2->_y = -v1->_y; - v2->_z = -v1->_z; - v2->fn3(); + v2._x = -v1._x; + v2._y = -v1._y; + v2._z = -v1._z; + v2.fn3(); } -void CStarView::randomizeVectors3(FVector *v1, FVector *v2) { - v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0; +void CStarView::randomizeVectors3(FVector &v1, FVector &v2) { + v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0; // TODO: Doublecheck - v2->_x = -v1->_x; - v2->_y = -v1->_y; - v2->_z = -v1->_z; - v2->fn3(); + v2._x = -v1._x; + v2._y = -v1._y; + v2._z = -v1._z; + v2.fn3(); } -void CStarView::randomizeVectors4(FVector *v1, FVector *v2) { - v1->_x = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_y = 3072.0 - g_vm->getRandomFloat() * -4096.0; - v1->_z = 3072.0 - g_vm->getRandomFloat() * -4096.0; +void CStarView::randomizeVectors4(FVector &v1, FVector &v2) { + v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0; + v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0; // TODO: Doublecheck - v2->_x = -v1->_x; - v2->_y = -v1->_y; - v2->_z = -v1->_z; - v2->fn3(); + v2._x = -v1._x; + v2._y = -v1._y; + v2._z = -v1._z; + v2.fn3(); } void CStarView::resizeSurface(CScreenManager *scrManager, int width, int height, CVideoSurface **surface) { diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h index e2978e6da0..0e271ec1ce 100644 --- a/engines/titanic/star_control/star_view.h +++ b/engines/titanic/star_control/star_view.h @@ -57,10 +57,10 @@ private: void fn18(CStarControlSub12 *sub12); void fn19(int v); - void randomizeVectors1(FVector *v1, FVector *v2); - void randomizeVectors2(FVector *v1, FVector *v2); - void randomizeVectors3(FVector *v1, FVector *v2); - void randomizeVectors4(FVector *v1, FVector *v2); + void randomizeVectors1(FVector &v1, FVector &v2); + void randomizeVectors2(FVector &v1, FVector &v2); + void randomizeVectors3(FVector &v1, FVector &v2); + void randomizeVectors4(FVector &v1, FVector &v2); /** * Handles resizing the surface |