aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/minigames/geisha/submarine.cpp
diff options
context:
space:
mode:
authorSven Hesse2012-06-06 02:52:19 +0200
committerSven Hesse2012-06-06 03:33:35 +0200
commitb83ac21f6008287414d59ad7f9c88b63bd93bac5 (patch)
tree9b87a703053367bcf8c20de47bfe732abbdcdc10 /engines/gob/minigames/geisha/submarine.cpp
parent93dda1b227fa11d1da2d923ca63a580343f6ba4e (diff)
downloadscummvm-rg350-b83ac21f6008287414d59ad7f9c88b63bd93bac5.tar.gz
scummvm-rg350-b83ac21f6008287414d59ad7f9c88b63bd93bac5.tar.bz2
scummvm-rg350-b83ac21f6008287414d59ad7f9c88b63bd93bac5.zip
GOB: Implement Penetration submarine shooting and dying
Shots don't result in bullets yet, though
Diffstat (limited to 'engines/gob/minigames/geisha/submarine.cpp')
-rw-r--r--engines/gob/minigames/geisha/submarine.cpp233
1 files changed, 233 insertions, 0 deletions
diff --git a/engines/gob/minigames/geisha/submarine.cpp b/engines/gob/minigames/geisha/submarine.cpp
new file mode 100644
index 0000000000..4a18c6e043
--- /dev/null
+++ b/engines/gob/minigames/geisha/submarine.cpp
@@ -0,0 +1,233 @@
+/* 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 "gob/minigames/geisha/submarine.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+enum Animation {
+ kAnimationDriveS = 4,
+ kAnimationDriveE = 5,
+ kAnimationDriveN = 6,
+ kAnimationDriveW = 7,
+ kAnimationDriveSE = 8,
+ kAnimationDriveNE = 9,
+ kAnimationDriveSW = 10,
+ kAnimationDriveNW = 11,
+ kAnimationShootS = 12,
+ kAnimationShootN = 13,
+ kAnimationShootW = 14,
+ kAnimationShootE = 15,
+ kAnimationShootNE = 16,
+ kAnimationShootSE = 17,
+ kAnimationShootSW = 18,
+ kAnimationShootNW = 19,
+ kAnimationExplodeN = 28,
+ kAnimationExplodeS = 29,
+ kAnimationExplodeW = 30,
+ kAnimationExplodeE = 31,
+ kAnimationExit = 32
+};
+
+
+Submarine::Submarine(const ANIFile &ani) : ANIObject(ani), _state(kStateNone) {
+ turn(kDirectionN);
+}
+
+Submarine::~Submarine() {
+}
+
+void Submarine::turn(Direction to) {
+ // Nothing to do
+ if ((_state == kStateMove) && (_direction == to))
+ return;
+
+ _state = kStateMove;
+ _direction = to;
+
+ setAnimation(directionToMove(_direction));
+ setMode(kModeContinuous);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::shoot() {
+ _state = kStateShoot;
+
+ setAnimation(directionToShoot(_direction));
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::die() {
+ _state = kStateDie;
+
+ setAnimation(directionToExplode(_direction));
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::leave() {
+ _state = kStateExit;
+
+ setAnimation(kAnimationExit);
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::advance() {
+ ANIObject::advance();
+
+ switch (_state) {
+ case kStateShoot:
+ if (isPaused())
+ turn(_direction);
+ break;
+
+ case kStateExit:
+ if (isPaused()) {
+ _state = kStateExited;
+
+ setVisible(true);
+ }
+
+ break;
+
+ case kStateDie:
+ if (isPaused())
+ _state = kStateDead;
+ break;
+
+ default:
+ break;
+ }
+}
+
+bool Submarine::canMove() const {
+ return (_state == kStateMove) || (_state == kStateShoot);
+}
+
+bool Submarine::isDead() const {
+ return _state == kStateDead;
+}
+
+uint16 Submarine::directionToMove(Direction direction) const {
+ switch (direction) {
+ case kDirectionN:
+ return kAnimationDriveN;
+
+ case kDirectionNE:
+ return kAnimationDriveNE;
+
+ case kDirectionE:
+ return kAnimationDriveE;
+
+ case kDirectionSE:
+ return kAnimationDriveSE;
+
+ case kDirectionS:
+ return kAnimationDriveS;
+
+ case kDirectionSW:
+ return kAnimationDriveSW;
+
+ case kDirectionW:
+ return kAnimationDriveW;
+
+ case kDirectionNW:
+ return kAnimationDriveNW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+uint16 Submarine::directionToShoot(Direction direction) const {
+ switch (direction) {
+ case kDirectionN:
+ return kAnimationShootN;
+
+ case kDirectionNE:
+ return kAnimationShootNE;
+
+ case kDirectionE:
+ return kAnimationShootE;
+
+ case kDirectionSE:
+ return kAnimationShootSE;
+
+ case kDirectionS:
+ return kAnimationShootS;
+
+ case kDirectionSW:
+ return kAnimationShootSW;
+
+ case kDirectionW:
+ return kAnimationShootW;
+
+ case kDirectionNW:
+ return kAnimationShootNW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+uint16 Submarine::directionToExplode(Direction direction) const {
+ // Only 4 exploding animations (spinning clockwise)
+
+ switch (direction) {
+ case kDirectionNW:
+ case kDirectionN:
+ return kAnimationExplodeN;
+
+ case kDirectionNE:
+ case kDirectionE:
+ return kAnimationExplodeE;
+
+ case kDirectionSE:
+ case kDirectionS:
+ return kAnimationExplodeS;
+
+ case kDirectionSW:
+ case kDirectionW:
+ return kAnimationExplodeW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob