aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2011-09-15 21:22:13 +0200
committerSven Hesse2011-09-15 21:24:08 +0200
commita607247262a7dcb5698d601da9529a856aa7a411 (patch)
treed0d03039f052f3129d3fd43720c663c2f93321db /engines
parent79f2bb52b655e73badef5155b7c772c705ae44e9 (diff)
downloadscummvm-rg350-a607247262a7dcb5698d601da9529a856aa7a411.tar.gz
scummvm-rg350-a607247262a7dcb5698d601da9529a856aa7a411.tar.bz2
scummvm-rg350-a607247262a7dcb5698d601da9529a856aa7a411.zip
GOB: Randomize when the evil fishes enter and leave
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/minigames/geisha/diving.cpp59
-rw-r--r--engines/gob/minigames/geisha/diving.h12
2 files changed, 49 insertions, 22 deletions
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 45bbdb1049..3cb2e00987 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -69,10 +69,8 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
_vm->_video->retrace();
while (!_vm->shouldQuit()) {
- evilFishEnter();
-
checkShots();
-
+ updateEvilFish();
updateAnims();
_vm->_draw->animateCursor(1);
@@ -124,8 +122,12 @@ void Diving::init() {
_heart->setVisible(true);
_heart->setPause(true);
- for (uint i = 0; i < kEvilFishCount; i++)
- _evilFish[i] = new EvilFish(*_objects, 320, 0, 0, 0, 0, 0);
+ for (uint i = 0; i < kEvilFishCount; i++) {
+ _evilFish[i].enterAt = 0;
+ _evilFish[i].leaveAt = 0;
+
+ _evilFish[i].evilFish = new EvilFish(*_objects, 320, 0, 0, 0, 0, 0);
+ }
for (uint i = 0; i < kMaxShotCount; i++) {
_shot[i] = new ANIObject(*_objects);
@@ -148,7 +150,7 @@ void Diving::init() {
for (uint i = 0; i < kMaxShotCount; i++)
_anims.push_back(_shot[i]);
for (uint i = 0; i < kEvilFishCount; i++)
- _anims.push_back(_evilFish[i]);
+ _anims.push_back(_evilFish[i].evilFish);
_anims.push_back(_lungs);
_anims.push_back(_heart);
@@ -178,9 +180,9 @@ void Diving::deinit() {
}
for (uint i = 0; i < kEvilFishCount; i++) {
- delete _evilFish[i];
+ delete _evilFish[i].evilFish;
- _evilFish[i] = 0;
+ _evilFish[i].evilFish = 0;
}
delete _heart;
@@ -234,20 +236,39 @@ void Diving::initCursor() {
_vm->_draw->_cursorHotspotY = 8;
}
-void Diving::evilFishEnter() {
+void Diving::updateEvilFish() {
for (uint i = 0; i < kEvilFishCount; i++) {
- EvilFish &fish = *_evilFish[i];
+ ManagedEvilFish &fish = _evilFish[i];
+
+ if (fish.evilFish->isVisible()) {
+ // Evil fishes leave on their own after 30s - 40s
- if (fish.isVisible())
- continue;
+ fish.enterAt = 0;
- int fishType = _vm->_util->getRandom(kEvilFishTypeCount);
- fish.mutate(kEvilFishTypes[fishType][0], kEvilFishTypes[fishType][1],
- kEvilFishTypes[fishType][2], kEvilFishTypes[fishType][3],
- kEvilFishTypes[fishType][4]);
+ if (fish.leaveAt == 0)
+ fish.leaveAt = _vm->_util->getTimeKey() + 30000 + _vm->_util->getRandom(10000);
- fish.enter((EvilFish::Direction)_vm->_util->getRandom(2),
- 36 + _vm->_util->getRandom(3) * 40);
+ if (_vm->_util->getTimeKey() >= fish.leaveAt)
+ fish.evilFish->leave();
+
+ } else {
+ // Evil fishes enter the screen in 2s - 10s
+
+ fish.leaveAt = 0;
+
+ if (fish.enterAt == 0)
+ fish.enterAt = _vm->_util->getTimeKey() + 2000 + _vm->_util->getRandom(8000);
+
+ if (_vm->_util->getTimeKey() >= fish.enterAt) {
+ int fishType = _vm->_util->getRandom(kEvilFishTypeCount);
+ fish.evilFish->mutate(kEvilFishTypes[fishType][0], kEvilFishTypes[fishType][1],
+ kEvilFishTypes[fishType][2], kEvilFishTypes[fishType][3],
+ kEvilFishTypes[fishType][4]);
+
+ fish.evilFish->enter((EvilFish::Direction)_vm->_util->getRandom(2),
+ 36 + _vm->_util->getRandom(3) * 40);
+ }
+ }
}
}
@@ -337,7 +358,7 @@ void Diving::checkShots() {
shot.getPosition(x, y);
for (uint i = 0; i < kEvilFishCount; i++) {
- EvilFish &evilFish = *_evilFish[i];
+ EvilFish &evilFish = *_evilFish[i].evilFish;
if (evilFish.isIn(x + 8, y + 8)) {
evilFish.die();
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index e2f5dd428f..cb1abd8898 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -53,6 +53,13 @@ private:
static const uint kEvilFishCount = 3;
static const uint kMaxShotCount = 10;
+ struct ManagedEvilFish {
+ EvilFish *evilFish;
+
+ uint32 enterAt;
+ uint32 leaveAt;
+ };
+
GobEngine *_vm;
DECFile *_background;
@@ -64,7 +71,7 @@ private:
ANIObject *_lungs;
ANIObject *_heart;
- EvilFish *_evilFish[kEvilFishCount];
+ ManagedEvilFish _evilFish[kEvilFishCount];
ANIObject *_shot[kMaxShotCount];
@@ -91,11 +98,10 @@ private:
void initScreen();
void initCursor();
- void evilFishEnter();
-
void foundBlackPearl();
void foundWhitePearl();
+ void updateEvilFish();
void updateAnims();
int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);