[Scummvm-cvs-logs] scummvm master -> e0209358b7bcd71993e2665433a1178156459fe2

DrMcCoy drmccoy at drmccoy.de
Thu Jan 26 21:15:55 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e0209358b7 GOB: Add pearls scrolling by on the ocean floor


Commit: e0209358b7bcd71993e2665433a1178156459fe2
    https://github.com/scummvm/scummvm/commit/e0209358b7bcd71993e2665433a1178156459fe2
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-01-26T12:13:38-08:00

Commit Message:
GOB: Add pearls scrolling by on the ocean floor

Changed paths:
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 8fe3d63..556d54e 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -68,6 +68,8 @@ Diving::~Diving() {
 }
 
 bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
+	_hasPearlLocation = hasPearlLocation;
+
 	init();
 	initScreen();
 	initCursor();
@@ -81,6 +83,7 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 		updateEvilFish();
 		updateDecorFish();
 		updatePlants();
+		updatePearl();
 		updateAnims();
 
 		_vm->_draw->animateCursor(1);
@@ -155,6 +158,11 @@ void Diving::init() {
 		_plant[i].plant = new ANIObject(*_objects);
 	}
 
+	_pearl.pearl = new ANIObject(*_objects);
+	_pearl.black = false;
+
+	_pearl.pearl->setAnimation(4);
+
 	_decorFish[0].decorFish->setAnimation( 6); // Jellyfish
 	_decorFish[0].deltaX = 0;
 
@@ -184,6 +192,7 @@ void Diving::init() {
 	_anims.push_back(_water);
 	for (uint i = 0; i < kMaxShotCount; i++)
 		_anims.push_back(_shot[i]);
+	_anims.push_back(_pearl.pearl);
 	for (uint i = 0; i < kDecorFishCount; i++)
 		_anims.push_back(_decorFish[i].decorFish);
 	for (uint i = 0; i < kEvilFishCount; i++)
@@ -236,6 +245,9 @@ void Diving::deinit() {
 		_plant[i].plant = 0;
 	}
 
+	delete _pearl.pearl;
+	_pearl.pearl = 0;
+
 	delete _heart;
 	delete _lungs;
 	delete _water;
@@ -316,6 +328,27 @@ void Diving::enterPlant(ManagedPlant &plant, int16 prevPlantX) {
 	plant.plant->setPosition(plant.x, plant.y);
 	plant.plant->setVisible(true);
 	plant.plant->setPause(false);
+
+	if (plant.x > 320)
+		enterPearl(plant.x);
+}
+
+void Diving::enterPearl(int16 x) {
+	// Only one pearl is ever visible
+	if (_pearl.pearl->isVisible())
+		return;
+
+	// Only every 4th potential pearl position has a pearl
+	if (_vm->_util->getRandom(4) != 0)
+		return;
+
+	// Every 5th pearl is a black one, but only if the location is correct
+	_pearl.black = _hasPearlLocation && (_vm->_util->getRandom(5) == 0);
+
+	_pearl.pearl->setPosition(x + 80, 130);
+
+	_pearl.pearl->setVisible(true);
+	_pearl.pearl->setPause(false);
 }
 
 void Diving::updateEvilFish() {
@@ -424,6 +457,25 @@ void Diving::updatePlants() {
 	}
 }
 
+void Diving::updatePearl() {
+	if (!_pearl.pearl->isVisible())
+		return;
+
+	// Move the pearl
+	int16 x, y, width, height;
+	_pearl.pearl->getPosition(x, y);
+	_pearl.pearl->setPosition(x - 5, y);
+
+	// Check if the pearl has left the screen
+	_pearl.pearl->getFramePosition(x, y);
+	_pearl.pearl->getFrameSize(width, height);
+
+	if ((x + width) <= 0) {
+		_pearl.pearl->setVisible(false);
+		_pearl.pearl->setPause(true);
+	}
+}
+
 void Diving::foundBlackPearl() {
 	_blackPearlCount++;
 
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index af22440..ee2f8d8 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -96,6 +96,12 @@ private:
 		int16 x, y;
 	};
 
+	struct ManagedPearl {
+		ANIObject *pearl;
+
+		bool black;
+	};
+
 	GobEngine *_vm;
 
 	DECFile *_background;
@@ -110,6 +116,7 @@ private:
 	ManagedEvilFish  _evilFish[kEvilFishCount];
 	ManagedDecorFish _decorFish[kDecorFishCount];
 	ManagedPlant     _plant[kPlantCount];
+	ManagedPearl     _pearl;
 
 	ANIObject *_shot[kMaxShotCount];
 
@@ -129,6 +136,8 @@ private:
 	SoundDesc _soundWhitePearl;
 	SoundDesc _soundBlackPearl;
 
+	bool _hasPearlLocation;
+
 
 	void init();
 	void deinit();
@@ -138,6 +147,7 @@ private:
 	void initPlants();
 
 	void enterPlant(ManagedPlant &plant, int16 prevPlantX);
+	void enterPearl(int16 x);
 
 	void foundBlackPearl();
 	void foundWhitePearl();
@@ -145,6 +155,7 @@ private:
 	void updateEvilFish();
 	void updateDecorFish();
 	void updatePlants();
+	void updatePearl();
 	void updateAnims();
 
 	int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);






More information about the Scummvm-git-logs mailing list