diff options
author | Sven Hesse | 2011-09-18 17:01:59 +0200 |
---|---|---|
committer | Sven Hesse | 2011-09-18 17:02:45 +0200 |
commit | a1825e4d02b179233d0f8074e5c38136959a9eeb (patch) | |
tree | d176e43fc533ab465567cc7f9278161de51c21a7 /engines/gob/minigames/geisha | |
parent | e360d35567836a8f1e3cee268a9671e414db1883 (diff) | |
download | scummvm-rg350-a1825e4d02b179233d0f8074e5c38136959a9eeb.tar.gz scummvm-rg350-a1825e4d02b179233d0f8074e5c38136959a9eeb.tar.bz2 scummvm-rg350-a1825e4d02b179233d0f8074e5c38136959a9eeb.zip |
GOB: At the decorative fishes in the Diving minigame
Diffstat (limited to 'engines/gob/minigames/geisha')
-rw-r--r-- | engines/gob/minigames/geisha/diving.cpp | 62 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/diving.h | 16 |
2 files changed, 75 insertions, 3 deletions
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp index 501f13c8cb..e3bc69a503 100644 --- a/engines/gob/minigames/geisha/diving.cpp +++ b/engines/gob/minigames/geisha/diving.cpp @@ -70,6 +70,7 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) { while (!_vm->shouldQuit()) { checkShots(); updateEvilFish(); + updateDecorFish(); updateAnims(); _vm->_draw->animateCursor(1); @@ -128,6 +129,21 @@ void Diving::init() { _evilFish[i].evilFish = new EvilFish(*_objects, 320, 0, 0, 0, 0, 0); } + for (uint i = 0; i < kDecorFishCount; i++) { + _decorFish[i].enterAt = 0; + + _decorFish[i].decorFish = new ANIObject(*_objects); + } + + _decorFish[0].decorFish->setAnimation( 6); // Jellyfish + _decorFish[0].deltaX = 0; + + _decorFish[1].decorFish->setAnimation(32); // Swarm of red/green fish + _decorFish[1].deltaX = -6; + + _decorFish[2].decorFish->setAnimation(33); // Swarm of orange fish + _decorFish[2].deltaX = -6; + for (uint i = 0; i < kMaxShotCount; i++) { _shot[i] = new ANIObject(*_objects); @@ -148,6 +164,8 @@ void Diving::init() { _anims.push_back(_water); for (uint i = 0; i < kMaxShotCount; i++) _anims.push_back(_shot[i]); + for (uint i = 0; i < kDecorFishCount; i++) + _anims.push_back(_decorFish[i].decorFish); for (uint i = 0; i < kEvilFishCount; i++) _anims.push_back(_evilFish[i].evilFish); _anims.push_back(_lungs); @@ -184,6 +202,12 @@ void Diving::deinit() { _evilFish[i].evilFish = 0; } + for (uint i = 0; i < kDecorFishCount; i++) { + delete _decorFish[i].decorFish; + + _decorFish[i].decorFish = 0; + } + delete _heart; delete _lungs; delete _water; @@ -271,6 +295,44 @@ void Diving::updateEvilFish() { } } +void Diving::updateDecorFish() { + for (uint i = 0; i < kDecorFishCount; i++) { + ManagedDecorFish &fish = _decorFish[i]; + + if (fish.decorFish->isVisible()) { + // Move the fish + int16 x, y; + fish.decorFish->getPosition(x, y); + fish.decorFish->setPosition(x + fish.deltaX, y); + + // Check if the fish has left the screen + int16 width, height; + fish.decorFish->getFramePosition(x, y); + fish.decorFish->getFrameSize(width, height); + + if ((x + width) <= 0) { + fish.decorFish->setVisible(false); + fish.decorFish->setPause(true); + + fish.enterAt = 0; + } + + } else { + // Decor fishes enter the screen every 0s - 10s + + if (fish.enterAt == 0) + fish.enterAt = _vm->_util->getTimeKey() + _vm->_util->getRandom(10000); + + if (_vm->_util->getTimeKey() >= fish.enterAt) { + fish.decorFish->rewind(); + fish.decorFish->setPosition(320, 30 + _vm->_util->getRandom(100)); + fish.decorFish->setVisible(true); + fish.decorFish->setPause(false); + } + } + } +} + void Diving::foundBlackPearl() { _blackPearlCount++; diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h index 962aaf8072..e386d783d7 100644 --- a/engines/gob/minigames/geisha/diving.h +++ b/engines/gob/minigames/geisha/diving.h @@ -50,8 +50,9 @@ public: bool play(uint16 playerCount, bool hasPearlLocation); private: - static const uint kEvilFishCount = 3; - static const uint kMaxShotCount = 10; + static const uint kEvilFishCount = 3; + static const uint kDecorFishCount = 3; + static const uint kMaxShotCount = 10; struct ManagedEvilFish { EvilFish *evilFish; @@ -60,6 +61,13 @@ private: uint32 leaveAt; }; + struct ManagedDecorFish { + ANIObject *decorFish; + + uint32 enterAt; + int8 deltaX; + }; + GobEngine *_vm; DECFile *_background; @@ -71,7 +79,8 @@ private: ANIObject *_lungs; ANIObject *_heart; - ManagedEvilFish _evilFish[kEvilFishCount]; + ManagedEvilFish _evilFish[kEvilFishCount]; + ManagedDecorFish _decorFish[kDecorFishCount]; ANIObject *_shot[kMaxShotCount]; @@ -102,6 +111,7 @@ private: void foundWhitePearl(); void updateEvilFish(); + void updateDecorFish(); void updateAnims(); int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); |