[Scummvm-cvs-logs] scummvm master -> 3d537e763c85bb3f16825c8b47894335568278a0
DrMcCoy
drmccoy at drmccoy.de
Thu Jun 7 04:21:53 CEST 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:
95454ab52c GOB: Better controls in Geisha's Penetration
3d537e763c GOB: Handle Penetration shooting animations more cleverly
Commit: 95454ab52c3e8f251b08aa62b18f071374de85b9
https://github.com/scummvm/scummvm/commit/95454ab52c3e8f251b08aa62b18f071374de85b9
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-06-06T19:21:29-07:00
Commit Message:
GOB: Better controls in Geisha's Penetration
You can actually move diagonally now
Changed paths:
engines/gob/minigames/geisha/penetration.cpp
engines/gob/minigames/geisha/penetration.h
engines/gob/minigames/geisha/submarine.cpp
engines/gob/minigames/geisha/submarine.h
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 1bcc42a..72c53cb 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/events.h"
+
#include "gob/global.h"
#include "gob/util.h"
#include "gob/palanim.h"
@@ -410,7 +412,7 @@ bool Penetration::play(bool hasAccessPass, bool hasMaxEnergy, bool testMode) {
_vm->_draw->blitInvalidated();
_vm->_video->retrace();
- while (!_vm->shouldQuit() && !isDead() && !hasWon()) {
+ while (!_vm->shouldQuit() && !_quit && !isDead() && !hasWon()) {
updateAnims();
// Draw, fade in if necessary and wait for the end of the frame
@@ -418,19 +420,11 @@ bool Penetration::play(bool hasAccessPass, bool hasMaxEnergy, bool testMode) {
fadeIn();
_vm->_util->waitEndFrame();
- // Handle input
- _vm->_util->processInput();
-
- int16 mouseX, mouseY;
- MouseButtons mouseButtons;
-
- int16 key = checkInput(mouseX, mouseY, mouseButtons);
- // Aborting the game
- if (key == kKeyEscape)
- break;
+ // Handle the input
+ checkInput();
// Handle the sub movement
- handleSub(key);
+ handleSub();
checkExited();
}
@@ -449,6 +443,10 @@ void Penetration::init() {
_vm->_sound->sampleLoad(&_soundShoot , SOUND_SND, "tirgim.snd");
_vm->_sound->sampleLoad(&_soundExit , SOUND_SND, "trouve.snd");
+ _quit = false;
+ for (int i = 0; i < kKeyCount; i++)
+ _keys[i] = false;
+
_background->clear();
_vm->_video->drawPackedSprite("hyprmef2.cmp", *_background);
@@ -731,10 +729,44 @@ void Penetration::initScreen() {
_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
}
-int16 Penetration::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) {
- _vm->_util->getMouseState(&mouseX, &mouseY, &mouseButtons);
+void Penetration::checkInput() {
+ Common::Event event;
+ Common::EventManager *eventMan = g_system->getEventManager();
+
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ _quit = true;
+ else if (event.kbd.keycode == Common::KEYCODE_UP)
+ _keys[kKeyUp ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_DOWN)
+ _keys[kKeyDown ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_LEFT)
+ _keys[kKeyLeft ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
+ _keys[kKeyRight] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ _keys[kKeySpace] = true;
+ break;
+
+ case Common::EVENT_KEYUP:
+ if (event.kbd.keycode == Common::KEYCODE_UP)
+ _keys[kKeyUp ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_DOWN)
+ _keys[kKeyDown ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_LEFT)
+ _keys[kKeyLeft ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
+ _keys[kKeyRight] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ _keys[kKeySpace] = false;
+ break;
- return _vm->_util->checkKey();
+ default:
+ break;
+ }
+ }
}
bool Penetration::isWalkable(int16 x, int16 y) const {
@@ -744,16 +776,13 @@ bool Penetration::isWalkable(int16 x, int16 y) const {
return _walkMap[y * kMapWidth + x];
}
-void Penetration::handleSub(int16 key) {
- if (key == kKeyLeft)
- subMove(-5, 0, Submarine::kDirectionW);
- else if (key == kKeyRight)
- subMove( 5, 0, Submarine::kDirectionE);
- else if (key == kKeyUp)
- subMove( 0, -5, Submarine::kDirectionN);
- else if (key == kKeyDown)
- subMove( 0, 5, Submarine::kDirectionS);
- else if (key == kKeySpace)
+void Penetration::handleSub() {
+ int x, y;
+ Submarine::Direction direction = getDirection(x, y);
+
+ subMove(x, y, direction);
+
+ if (_keys[kKeySpace])
subShoot();
}
@@ -802,6 +831,30 @@ void Penetration::subShoot() {
_vm->_sound->blasterPlay(&_soundShoot, 1, 0);
}
+Submarine::Direction Penetration::getDirection(int &x, int &y) const {
+ x = _keys[kKeyRight] ? 3 : (_keys[kKeyLeft] ? -3 : 0);
+ y = _keys[kKeyDown ] ? 3 : (_keys[kKeyUp ] ? -3 : 0);
+
+ if ((x > 0) && (y > 0))
+ return Submarine::kDirectionSE;
+ if ((x > 0) && (y < 0))
+ return Submarine::kDirectionNE;
+ if ((x < 0) && (y > 0))
+ return Submarine::kDirectionSW;
+ if ((x < 0) && (y < 0))
+ return Submarine::kDirectionNW;
+ if (x > 0)
+ return Submarine::kDirectionE;
+ if (x < 0)
+ return Submarine::kDirectionW;
+ if (y > 0)
+ return Submarine::kDirectionS;
+ if (y < 0)
+ return Submarine::kDirectionN;
+
+ return Submarine::kDirectionNone;
+}
+
void Penetration::checkShields() {
for (Common::List<Position>::iterator pos = _shields.begin(); pos != _shields.end(); ++pos) {
if ((pos->x == _sub->x) && (pos->y == _sub->y)) {
diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h
index 3f03bfa..0f36453 100644
--- a/engines/gob/minigames/geisha/penetration.h
+++ b/engines/gob/minigames/geisha/penetration.h
@@ -94,6 +94,15 @@ private:
void setPosition(uint16 pX, uint16 pY);
};
+ enum Keys {
+ kKeyUp = 0,
+ kKeyDown,
+ kKeyLeft,
+ kKeyRight,
+ kKeySpace,
+ kKeyCount
+ };
+
GobEngine *_vm;
bool _hasAccessPass;
@@ -102,6 +111,9 @@ private:
bool _needFadeIn;
+ bool _quit;
+ bool _keys[kKeyCount];
+
Surface *_background;
CMPFile *_sprites;
ANIFile *_objects;
@@ -146,12 +158,14 @@ private:
void updateAnims();
- int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
+ void checkInput();
- void handleSub(int16 key);
+ void handleSub();
void subMove(int x, int y, Submarine::Direction direction);
void subShoot();
+ Submarine::Direction getDirection(int &x, int &y) const;
+
bool isWalkable(int16 x, int16 y) const;
void checkExits();
diff --git a/engines/gob/minigames/geisha/submarine.cpp b/engines/gob/minigames/geisha/submarine.cpp
index 0f3f936..c61f49f 100644
--- a/engines/gob/minigames/geisha/submarine.cpp
+++ b/engines/gob/minigames/geisha/submarine.cpp
@@ -60,7 +60,7 @@ Submarine::~Submarine() {
void Submarine::turn(Direction to) {
// Nothing to do
- if ((_state == kStateMove) && (_direction == to))
+ if ((to == kDirectionNone) || ((_state == kStateMove) && (_direction == to)))
return;
_state = kStateMove;
diff --git a/engines/gob/minigames/geisha/submarine.h b/engines/gob/minigames/geisha/submarine.h
index d14e4e9..2455ef9 100644
--- a/engines/gob/minigames/geisha/submarine.h
+++ b/engines/gob/minigames/geisha/submarine.h
@@ -33,6 +33,7 @@ namespace Geisha {
class Submarine : public ANIObject {
public:
enum Direction {
+ kDirectionNone,
kDirectionN,
kDirectionNE,
kDirectionE,
Commit: 3d537e763c85bb3f16825c8b47894335568278a0
https://github.com/scummvm/scummvm/commit/3d537e763c85bb3f16825c8b47894335568278a0
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-06-06T19:21:29-07:00
Commit Message:
GOB: Handle Penetration shooting animations more cleverly
Still no bullets, though :P
Changed paths:
engines/gob/aniobject.cpp
engines/gob/aniobject.h
engines/gob/minigames/geisha/penetration.cpp
engines/gob/minigames/geisha/submarine.cpp
engines/gob/minigames/geisha/submarine.h
diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp
index 54534cd..8d739fb 100644
--- a/engines/gob/aniobject.cpp
+++ b/engines/gob/aniobject.cpp
@@ -76,6 +76,10 @@ void ANIObject::rewind() {
_frame = 0;
}
+void ANIObject::setFrame(uint16 frame) {
+ _frame = frame % _ani->getAnimationInfo(_animation).frameCount;
+}
+
void ANIObject::setPosition() {
// CMP "animations" have no default position
if (_cmp)
diff --git a/engines/gob/aniobject.h b/engines/gob/aniobject.h
index 5ea1f75..00f42b4 100644
--- a/engines/gob/aniobject.h
+++ b/engines/gob/aniobject.h
@@ -84,6 +84,9 @@ public:
/** Rewind the current animation to the first frame. */
void rewind();
+ /** Set the animation to a specific frame. */
+ void setFrame(uint16 frame);
+
/** Return the current animation number. */
uint16 getAnimation() const;
/** Return the current frame number. */
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 72c53cb..e260d3c 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -823,7 +823,7 @@ void Penetration::subMove(int x, int y, Submarine::Direction direction) {
}
void Penetration::subShoot() {
- if (!_sub->sub->canMove())
+ if (!_sub->sub->canMove() || _sub->sub->isShooting())
return;
_sub->sub->shoot();
diff --git a/engines/gob/minigames/geisha/submarine.cpp b/engines/gob/minigames/geisha/submarine.cpp
index c61f49f..9c12a56 100644
--- a/engines/gob/minigames/geisha/submarine.cpp
+++ b/engines/gob/minigames/geisha/submarine.cpp
@@ -51,7 +51,7 @@ enum Animation {
};
-Submarine::Submarine(const ANIFile &ani) : ANIObject(ani), _state(kStateNone) {
+Submarine::Submarine(const ANIFile &ani) : ANIObject(ani), _state(kStateMove) {
turn(kDirectionN);
}
@@ -63,13 +63,21 @@ void Submarine::turn(Direction to) {
if ((to == kDirectionNone) || ((_state == kStateMove) && (_direction == to)))
return;
- _state = kStateMove;
_direction = to;
- setAnimation(directionToMove(_direction));
- setMode(kModeContinuous);
+ move();
+}
+
+void Submarine::move() {
+ uint16 frame = getFrame();
+ uint16 anim = (_state == kStateShoot) ? directionToShoot(_direction) : directionToMove(_direction);
+
+ setAnimation(anim);
+ setFrame(frame);
setPause(false);
setVisible(true);
+
+ setMode((_state == kStateShoot) ? kModeOnce : kModeContinuous);
}
void Submarine::shoot() {
@@ -104,8 +112,11 @@ void Submarine::advance() {
switch (_state) {
case kStateShoot:
- if (isPaused())
- turn(_direction);
+ if (isPaused()) {
+ _state = kStateMove;
+
+ move();
+ }
break;
case kStateExit:
@@ -132,6 +143,10 @@ bool Submarine::isDead() const {
return _state == kStateDead;
}
+bool Submarine::isShooting() const {
+ return _state == kStateShoot;
+}
+
bool Submarine::hasExited() const {
return _state == kStateExited;
}
diff --git a/engines/gob/minigames/geisha/submarine.h b/engines/gob/minigames/geisha/submarine.h
index 2455ef9..8a6d679 100644
--- a/engines/gob/minigames/geisha/submarine.h
+++ b/engines/gob/minigames/geisha/submarine.h
@@ -68,6 +68,9 @@ public:
/** Is the submarine dead? */
bool isDead() const;
+ /** Is the submarine shooting? */
+ bool isShooting() const;
+
/** Has the submarine finished exiting the level? */
bool hasExited() const;
@@ -91,6 +94,8 @@ private:
uint16 directionToShoot(Direction direction) const;
/** Map the directions to explode animation indices. */
uint16 directionToExplode(Direction direction) const;
+
+ void move();
};
} // End of namespace Geisha
More information about the Scummvm-git-logs
mailing list