diff options
author | Sven Hesse | 2012-06-05 17:01:40 +0200 |
---|---|---|
committer | Sven Hesse | 2012-06-05 17:01:40 +0200 |
commit | 4392e4d7aab9114ff66a1fcda34d21f404b4ebcd (patch) | |
tree | 367134fbcfdf9761f3d344b20828c17d9e1570d8 /engines/gob/minigames | |
parent | 73776406686709bc79ff9c6423937dce0e43c5d6 (diff) | |
download | scummvm-rg350-4392e4d7aab9114ff66a1fcda34d21f404b4ebcd.tar.gz scummvm-rg350-4392e4d7aab9114ff66a1fcda34d21f404b4ebcd.tar.bz2 scummvm-rg350-4392e4d7aab9114ff66a1fcda34d21f404b4ebcd.zip |
GOB: Implement health gain/loss for mouths
Diffstat (limited to 'engines/gob/minigames')
-rw-r--r-- | engines/gob/minigames/geisha/meter.cpp | 22 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/meter.h | 8 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/penetration.cpp | 24 | ||||
-rw-r--r-- | engines/gob/minigames/geisha/penetration.h | 3 |
4 files changed, 44 insertions, 13 deletions
diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp index 9dcc717e48..719ecf3d18 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 d3e82cb32e..30dc826de0 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 1321842d07..a188995372 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 00ddb4bdba..488396ea32 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 |