[Scummvm-cvs-logs] scummvm master -> 4392e4d7aab9114ff66a1fcda34d21f404b4ebcd

DrMcCoy drmccoy at drmccoy.de
Tue Jun 5 17:03:36 CEST 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:
4392e4d7aa GOB: Implement health gain/loss for mouths


Commit: 4392e4d7aab9114ff66a1fcda34d21f404b4ebcd
    https://github.com/scummvm/scummvm/commit/4392e4d7aab9114ff66a1fcda34d21f404b4ebcd
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-06-05T08:01:40-07:00

Commit Message:
GOB: Implement health gain/loss for mouths

Changed paths:
    engines/gob/minigames/geisha/meter.cpp
    engines/gob/minigames/geisha/meter.h
    engines/gob/minigames/geisha/penetration.cpp
    engines/gob/minigames/geisha/penetration.h



diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp
index 9dcc717..719ecf3 100644
--- a/engines/gob/minigames/geisha/meter.cpp
+++ b/engines/gob/minigames/geisha/meter.cpp
@@ -63,22 +63,36 @@ void Meter::setMaxValue() {
 	setValue(_maxValue);
 }
 
-void Meter::increase(int32 n) {
+int32 Meter::increase(int32 n) {
+	if (n < 0)
+		return decrease(-n);
+
+	int32 overflow = MAX(0, (_value + n) - _maxValue);
+
 	int32 value = CLIP<int32>(_value + n, 0, _maxValue);
 	if (_value == value)
-		return;
+		return overflow;
 
 	_value = value;
 	_needUpdate = true;
+
+	return overflow;
 }
 
-void Meter::decrease(int32 n) {
+int32 Meter::decrease(int32 n) {
+	if (n < 0)
+		return increase(-n);
+
+	int32 underflow = -MIN(0, _value - n);
+
 	int32 value = CLIP<int32>(_value - n, 0, _maxValue);
 	if (_value == value)
-		return;
+		return underflow;
 
 	_value = value;
 	_needUpdate = true;
+
+	return underflow;
 }
 
 void Meter::draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom) {
diff --git a/engines/gob/minigames/geisha/meter.h b/engines/gob/minigames/geisha/meter.h
index d3e82cb..30dc826 100644
--- a/engines/gob/minigames/geisha/meter.h
+++ b/engines/gob/minigames/geisha/meter.h
@@ -55,10 +55,10 @@ public:
 	/** Set the current value the meter is measuring to the max value. */
 	void setMaxValue();
 
-	/** Increase the current value the meter is measuring. */
-	void increase(int32 n = 1);
-	/** Decrease the current value the meter is measuring. */
-	void decrease(int32 n = 1);
+	/** Increase the current value the meter is measuring, returning the overflow. */
+	int32 increase(int32 n = 1);
+	/** Decrease the current value the meter is measuring, returning the underflow. */
+	int32 decrease(int32 n = 1);
 
 	/** Draw the meter onto the surface and return the affected rectangle. */
 	void draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 1321842..a188995 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -226,8 +226,8 @@ Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _sprites(0),
 
 	_background = new Surface(320, 200, 1);
 
-	_shieldMeter = new Meter(11, 119, 92, 3, kColorShield, kColorBlack, 1020, Meter::kFillToRight);
-	_healthMeter = new Meter(11, 137, 92, 3, kColorHealth, kColorBlack, 1020, Meter::kFillToRight);
+	_shieldMeter = new Meter(11, 119, 92, 3, kColorShield, kColorBlack, 920, Meter::kFillToRight);
+	_healthMeter = new Meter(11, 137, 92, 3, kColorHealth, kColorBlack, 920, Meter::kFillToRight);
 
 	_map = new Surface(kMapWidth  * kMapTileWidth  + kPlayAreaWidth ,
 	                   kMapHeight * kMapTileHeight + kPlayAreaHeight, 1);
@@ -563,15 +563,29 @@ void Penetration::checkMouths() {
 
 			m->mouth->activate();
 
-			// Play the mouth sound
-			if      (m->type == kMouthTypeBite)
+			// Play the mouth sound and do health gain/loss
+			if      (m->type == kMouthTypeBite) {
 				_vm->_sound->blasterPlay(&_soundBite, 1, 0);
-			else if (m->type == kMouthTypeKiss)
+				healthLose(230);
+			} else if (m->type == kMouthTypeKiss) {
 				_vm->_sound->blasterPlay(&_soundKiss, 1, 0);
+				healthGain(120);
+			}
 		}
 	}
 }
 
+void Penetration::healthGain(int amount) {
+	if (_shieldMeter->getValue() > 0)
+		_healthMeter->increase(_shieldMeter->increase(amount));
+	else
+		_healthMeter->increase(amount);
+}
+
+void Penetration::healthLose(int amount) {
+	_healthMeter->decrease(_shieldMeter->decrease(amount));
+}
+
 void Penetration::updateAnims() {
 	int16 left = 0, top = 0, right = 0, bottom = 0;
 
diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h
index 00ddb4b..488396e 100644
--- a/engines/gob/minigames/geisha/penetration.h
+++ b/engines/gob/minigames/geisha/penetration.h
@@ -132,6 +132,9 @@ private:
 
 	void checkShields();
 	void checkMouths();
+
+	void healthGain(int amount);
+	void healthLose(int amount);
 };
 
 } // End of namespace Geisha






More information about the Scummvm-git-logs mailing list