[Scummvm-cvs-logs] scummvm master -> 7650fca0405f62e62bdf81cb9f2acd8e7f14ca69

DrMcCoy drmccoy at drmccoy.de
Sat Jan 28 17:47:27 CET 2012


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

Summary:
9dd7035327 GOB: Add the air and health meters in Geisha's Diving minigame
7650fca040 GOB: Air gets used up and is refilled by breathing


Commit: 9dd703532706c049b14b4bc1e239c9cd08366f2a
    https://github.com/scummvm/scummvm/commit/9dd703532706c049b14b4bc1e239c9cd08366f2a
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-01-28T08:46:38-08:00

Commit Message:
GOB: Add the air and health meters in Geisha's Diving minigame

Changed paths:
  A engines/gob/minigames/geisha/meter.cpp
  A engines/gob/minigames/geisha/meter.h
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h
    engines/gob/module.mk



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 4b08a21..59ebe7f 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -32,6 +32,7 @@
 
 #include "gob/minigames/geisha/evilfish.h"
 #include "gob/minigames/geisha/oko.h"
+#include "gob/minigames/geisha/meter.h"
 #include "gob/minigames/geisha/diving.h"
 
 namespace Gob {
@@ -57,10 +58,14 @@ const Diving::PlantLevel Diving::kPlantLevels[] = {
 
 Diving::Diving(GobEngine *vm) : _vm(vm), _background(0),
 	_objects(0), _gui(0), _okoAnim(0), _lungs(0), _heart(0),
-	_blackPearl(0), _whitePearlCount(0), _blackPearlCount(0) {
+	_blackPearl(0), _airMeter(0), _healthMeter(0),
+	_whitePearlCount(0), _blackPearlCount(0) {
 
 	_blackPearl = new Surface(11, 8, 1);
 
+	_airMeter    = new Meter(4  , 195, 38, 2, 5, 7, 38, Meter::kFillToLeft);
+	_healthMeter = new Meter(276, 195, 38, 2, 6, 7, 38, Meter::kFillToLeft);
+
 	for (uint i = 0; i < kEvilFishCount; i++)
 		_evilFish[i].evilFish = 0;
 
@@ -79,6 +84,9 @@ Diving::Diving(GobEngine *vm) : _vm(vm), _background(0),
 }
 
 Diving::~Diving() {
+	delete _airMeter;
+	delete _healthMeter;
+
 	delete _blackPearl;
 
 	deinit();
@@ -234,6 +242,9 @@ void Diving::init() {
 	_anims.push_back(_oko);
 	_anims.push_back(_lungs);
 	_anims.push_back(_heart);
+
+	_airMeter->setValue(38);
+	_healthMeter->setValue(38);
 }
 
 void Diving::deinit() {
@@ -584,6 +595,13 @@ void Diving::updateAnims() {
 
 		(*a)->advance();
 	}
+
+	// Draw the meters
+	_airMeter->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+
+	_healthMeter->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
 }
 
 int16 Diving::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) {
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index b00252c..50a5d49 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -41,6 +41,7 @@ namespace Geisha {
 
 class EvilFish;
 class Oko;
+class Meter;
 
 /** Geisha's "Diving" minigame. */
 class Diving {
@@ -132,6 +133,9 @@ private:
 	uint8 _whitePearlCount;
 	uint8 _blackPearlCount;
 
+	Meter *_airMeter;
+	Meter *_healthMeter;
+
 	uint8 _currentShot;
 
 	SoundDesc _soundShoot;
diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp
new file mode 100644
index 0000000..82318a3
--- /dev/null
+++ b/engines/gob/minigames/geisha/meter.cpp
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/util.h"
+
+#include "gob/surface.h"
+
+#include "gob/minigames/geisha/meter.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+Meter::Meter(int16 x, int16 y, int16 width, int16 height, uint8 frontColor,
+             uint8 backColor, int32 maxValue, Direction direction) :
+	_x(x), _y(y), _width(width), _height(height), _frontColor(frontColor),
+	_backColor(backColor), _value(0), _maxValue(maxValue), _direction(direction),
+	_needUpdate(true), _surface(0) {
+
+}
+
+Meter::~Meter() {
+	delete _surface;
+}
+
+int32 Meter::getValue() const {
+	return _value;
+}
+
+void Meter::setValue(int32 value) {
+	value = CLIP<int32>(value, 0, _maxValue);
+	if (_value == value)
+		return;
+
+	_value = value;
+	_needUpdate = true;
+}
+
+void Meter::increase(int32 n) {
+	int32 value = CLIP<int32>(_value + n, 0, _maxValue);
+	if (_value == value)
+		return;
+
+	_value = value;
+	_needUpdate = true;
+}
+
+void Meter::decrease(int32 n) {
+	int32 value = CLIP<int32>(_value - n, 0, _maxValue);
+	if (_value == value)
+		return;
+
+	_value = value;
+	_needUpdate = true;
+}
+
+void Meter::draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom) {
+	if (!_surface) {
+		_surface = new Surface(_width, _height, dest.getBPP());
+		_needUpdate = true;
+	}
+
+	update();
+
+	left   = CLIP<int16>(_x              , 0, dest.getWidth () - 1);
+	top    = CLIP<int16>(_y              , 0, dest.getHeight() - 1);
+	right  = CLIP<int16>(_x + _width  - 1, 0, dest.getWidth () - 1);
+	bottom = CLIP<int16>(_y + _height - 1, 0, dest.getHeight() - 1);
+
+	dest.blit(*_surface, left - _x, top - _y, _width, _height, left, top);
+}
+
+void Meter::update() {
+	if (!_needUpdate)
+		return;
+
+	_needUpdate = false;
+
+	_surface->fill(_backColor);
+
+	int32 n = floor((((float) _width) / _maxValue * _value) + 0.5);
+	if (n <= 0)
+		return;
+
+	if (_direction == kFillToLeft)
+		_surface->fillRect(_width - n, 0, _width - 1, _height - 1, _frontColor);
+	else
+		_surface->fillRect(0         , 0, n - 1, _height - 1, _frontColor);
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/meter.h b/engines/gob/minigames/geisha/meter.h
new file mode 100644
index 0000000..3981287
--- /dev/null
+++ b/engines/gob/minigames/geisha/meter.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GOB_MINIGAMES_GEISHA_METER_H
+#define GOB_MINIGAMES_GEISHA_METER_H
+
+#include "gob/aniobject.h"
+
+namespace Gob {
+
+class Surface;
+
+namespace Geisha {
+
+/** A meter measuring a value. */
+class Meter {
+public:
+	enum Direction {
+		kFillToLeft,
+		kFillToRight
+	};
+
+	Meter(int16 x, int16 y, int16 width, int16 height,
+	      uint8 frontColor, uint8 backColor, int32 maxValue,
+	      Direction direction);
+	~Meter();
+
+	/** Return the current value the meter is measuring. */
+	int32 getValue() const;
+
+	/** Set the current value the meter is measuring. */
+	void setValue(int32 value);
+
+	/** 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);
+
+	/** Draw the meter onto the surface and return the affected rectangle. */
+	void draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
+
+private:
+	int16 _x;
+	int16 _y;
+	int16 _width;
+	int16 _height;
+
+	uint8 _frontColor;
+	uint8 _backColor;
+
+	int32 _value;
+	int32 _maxValue;
+
+	Direction _direction;
+
+	bool _needUpdate;
+
+	Surface *_surface;
+
+	void update();
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_METER_H
diff --git a/engines/gob/module.mk b/engines/gob/module.mk
index 6adf99f..09098f0 100644
--- a/engines/gob/module.mk
+++ b/engines/gob/module.mk
@@ -75,6 +75,7 @@ MODULE_OBJS := \
 	demos/batplayer.o \
 	minigames/geisha/evilfish.o \
 	minigames/geisha/oko.o \
+	minigames/geisha/meter.o \
 	minigames/geisha/diving.o \
 	minigames/geisha/penetration.o \
 	save/savefile.o \


Commit: 7650fca0405f62e62bdf81cb9f2acd8e7f14ca69
    https://github.com/scummvm/scummvm/commit/7650fca0405f62e62bdf81cb9f2acd8e7f14ca69
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-01-28T08:46:38-08:00

Commit Message:
GOB: Air gets used up and is refilled by breathing

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



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 59ebe7f..bd87be8 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -39,6 +39,9 @@ namespace Gob {
 
 namespace Geisha {
 
+static const uint8 kAirDecreaseRate = 15;
+
+
 const uint16 Diving::kEvilFishTypes[kEvilFishTypeCount][5] = {
 	{ 0, 14,  8,  9, 3}, // Shark
 	{15,  1, 12, 13, 3}, // Moray
@@ -105,6 +108,7 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 
 	while (!_vm->shouldQuit()) {
 		checkShots();
+		updateAirMeter();
 		updateEvilFish();
 		updateDecorFish();
 		updatePlants();
@@ -245,6 +249,8 @@ void Diving::init() {
 
 	_airMeter->setValue(38);
 	_healthMeter->setValue(38);
+
+	_airCycle = 0;
 }
 
 void Diving::deinit() {
@@ -393,6 +399,19 @@ void Diving::enterPearl(int16 x) {
 	_pearl.pearl->setPause(false);
 }
 
+void Diving::updateAirMeter() {
+	if (_oko->isBreathing()) {
+		_airCycle = 0;
+		_airMeter->increase();
+		return;
+	}
+
+	_airCycle = (_airCycle + 1) % kAirDecreaseRate;
+
+	if (_airCycle == 0)
+		_airMeter->decrease();
+}
+
 void Diving::updateEvilFish() {
 	for (uint i = 0; i < kEvilFishCount; i++) {
 		ManagedEvilFish &fish = _evilFish[i];
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index 50a5d49..2915e85 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -136,6 +136,8 @@ private:
 	Meter *_airMeter;
 	Meter *_healthMeter;
 
+	uint8 _airCycle;
+
 	uint8 _currentShot;
 
 	SoundDesc _soundShoot;
@@ -161,6 +163,7 @@ private:
 	void foundBlackPearl();
 	void foundWhitePearl();
 
+	void updateAirMeter();
 	void updateEvilFish();
 	void updateDecorFish();
 	void updatePlants();
diff --git a/engines/gob/minigames/geisha/oko.cpp b/engines/gob/minigames/geisha/oko.cpp
index 5da1947..23f460f 100644
--- a/engines/gob/minigames/geisha/oko.cpp
+++ b/engines/gob/minigames/geisha/oko.cpp
@@ -131,8 +131,8 @@ Oko::State Oko::getState() const {
 	return _state;
 }
 
-bool Oko::isAtBottom() const {
-	return _level >= (kLevelCount - 1);
+bool Oko::isBreathing() const {
+	return (_state == kStateBreathe) && ((getFrame() >= 9) && (getFrame() <= 30));
 }
 
 } // End of namespace Geisha
diff --git a/engines/gob/minigames/geisha/oko.h b/engines/gob/minigames/geisha/oko.h
index 0dee53c..3782493 100644
--- a/engines/gob/minigames/geisha/oko.h
+++ b/engines/gob/minigames/geisha/oko.h
@@ -57,7 +57,7 @@ public:
 
 	State getState() const;
 
-	bool isAtBottom() const;
+	bool isBreathing() const;
 
 private:
 	Sound *_sound;






More information about the Scummvm-git-logs mailing list