diff options
| -rw-r--r-- | engines/gob/aniobject.cpp | 4 | ||||
| -rw-r--r-- | engines/gob/aniobject.h | 3 | ||||
| -rw-r--r-- | engines/gob/minigames/geisha/penetration.cpp | 2 | ||||
| -rw-r--r-- | engines/gob/minigames/geisha/submarine.cpp | 27 | ||||
| -rw-r--r-- | engines/gob/minigames/geisha/submarine.h | 5 | 
5 files changed, 34 insertions, 7 deletions
| diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp index 54534cd60b..8d739fb3a4 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 5ea1f75401..00f42b43ce 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 72c53cb5c3..e260d3cae2 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 c61f49f22b..9c12a56a85 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 2455ef95c1..8a6d679bdd 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 | 
