aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-07-12 03:34:14 +0530
committerEugene Sandulenko2019-09-03 17:17:17 +0200
commit58512d2123339a137172516d1669fe6fced97d3e (patch)
tree9a8b6ebecc19bef5e8c22de84e1e6ac30d5ac01d
parent5b4602fdbee1cae593ccc8bc8b8d353a4274f4ac (diff)
downloadscummvm-rg350-58512d2123339a137172516d1669fe6fced97d3e.tar.gz
scummvm-rg350-58512d2123339a137172516d1669fe6fced97d3e.tar.bz2
scummvm-rg350-58512d2123339a137172516d1669fe6fced97d3e.zip
HDB: Add Bonus Star functions
-rw-r--r--engines/hdb/gfx.cpp71
-rw-r--r--engines/hdb/gfx.h15
2 files changed, 86 insertions, 0 deletions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 57a3d28f94..ddc397d901 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -26,6 +26,7 @@ namespace HDB {
Gfx::Gfx() {
_tLookupArray = NULL;
+ _starsInfo.active = false;
_gfxCache = new Common::Array<GfxCache *>;
_globalSurface.create(kScreenWidth, kScreenHeight, g_hdb->_format);
_pointerDisplayable = 1;
@@ -780,6 +781,76 @@ void Gfx::getCursor(int *x, int *y) {
*y = _cursorY;
}
+void Gfx::turnOnBonusStars(int which) {
+ int i;
+ _starsInfo.active = true;
+ for (i = 0; i < 10; i++)
+ _starsInfo.starAngle[i] = (36 * (i + 1)) - 10;
+ if (!_starsInfo.gfx[0]) {
+ switch (which) {
+ case 0: // Red Star
+ _starsInfo.gfx[0] = loadPic(SECRETSTAR_RED1);
+ _starsInfo.gfx[1] = loadPic(SECRETSTAR_RED2);
+ break;
+ case 1: // Green Star
+ _starsInfo.gfx[0] = loadPic(SECRETSTAR_GREEN1);
+ _starsInfo.gfx[1] = loadPic(SECRETSTAR_GREEN2);
+ break;
+ case 2: // Blue Star
+ _starsInfo.gfx[0] = loadPic(SECRETSTAR_BLUE1);
+ _starsInfo.gfx[1] = loadPic(SECRETSTAR_BLUE2);
+ break;
+ }
+ }
+
+ _starsInfo.radius = 0;
+ _starsInfo.angleSpeed = 25;
+ _starsInfo.timer = g_hdb->getTimeSlice() + 500;
+ _starsInfo.anim = 0;
+ _starsInfo.totalTime = g_hdb->getTimeSlice() + 5000; // 5 seconds long
+ g_hdb->_sound->playSound(SND_MONKEYSTONE_SECRET_STAR);
+}
+
+void Gfx::drawBonusStars() {
+ int i, w, h;
+
+ if (!_starsInfo.active)
+ return;
+
+ if (_starsInfo.timer < g_hdb->getTimeSlice()) {
+ _starsInfo.timer = g_hdb->getTimeSlice() + 500;
+ _starsInfo.anim = 1 - _starsInfo.anim;
+ }
+
+ w = _starsInfo.gfx[0]->_width / 2;
+ h = _starsInfo.gfx[0]->_height / 2;
+
+ for (i = 0; i < 10; i++) {
+ _starsInfo.gfx[_starsInfo.anim]->drawMasked(
+ (int)(480 / 2 + ((float)_starsInfo.radius / 2)) + (int)((double)_starsInfo.radius * _cosines->at(_starsInfo.starAngle[i]) - w),
+ (480 / 2) + (int)((double)_starsInfo.radius * _sines->at(_starsInfo.starAngle[i]) - h)
+ );
+
+ int angle = (int)(_starsInfo.starAngle[i] + _starsInfo.angleSpeed);
+ if (angle >= 360)
+ angle = 0;
+ _starsInfo.starAngle[i] = angle;
+ }
+
+ _starsInfo.radius++;
+ _starsInfo.angleSpeed -= 0.25;
+ if (_starsInfo.angleSpeed < 15)
+ _starsInfo.angleSpeed = 15;
+
+ // timed out?
+ if (_starsInfo.totalTime < g_hdb->getTimeSlice()) {
+ _starsInfo.active = false;
+ _starsInfo.gfx[0]->free();
+ _starsInfo.gfx[1]->free();
+ _starsInfo.gfx[0] = _starsInfo.gfx[1] = 0;
+ }
+}
+
Picture::Picture() : _width(0), _height(0), _name("") {
_surface.create(_width, _height, g_hdb->_format);
}
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index d113df4a58..a097b6f588 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -161,6 +161,11 @@ public:
return _cosines->at(index);
}
+ // Bonus star functions
+
+ void turnOnBonusStars(int which);
+ void drawBonusStars();
+
private:
int _numTiles;
TileLookup *_tLookupArray;
@@ -205,6 +210,16 @@ private:
Picture *_starField[4];
Picture *_skyClouds;
+ struct {
+ bool active;
+ int starAngle[10];
+ Picture *gfx[2];
+ uint32 timer;
+ int anim, radius;
+ double angleSpeed;
+ uint32 totalTime;
+ } _starsInfo;
+
// Cursor
int _cursorX, _cursorY;
Picture *_mousePointer[8]; // Gfx for screen pointer (4 Animations)