scummvm/engines/gnap/scenes/scene32.cpp

200 lines
4.9 KiB
C++
Raw Normal View History

2014-01-07 20:37:29 +00:00
/* 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 "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"
namespace Gnap {
enum {
kHSPlatypus = 0,
kHSExitTruck = 1,
kHSDevice = 2,
kHSWalkArea1 = 3,
kHSWalkArea2 = 4,
kHSWalkArea3 = 5,
kHSWalkArea4 = 6,
kHSWalkArea5 = 7,
kHSWalkArea6 = 8,
kHSWalkArea7 = 9,
kHSWalkArea8 = 10
};
2014-01-23 11:51:43 +00:00
enum {
kASLeaveScene = 0
};
2014-01-07 20:37:29 +00:00
int GnapEngine::scene32_init() {
_gameSys->setAnimation(0, 0, 0);
return isFlag(kGFPlatypusTalkingToAssistant) ? 0xF : 0x10;
2014-01-07 20:37:29 +00:00
}
void GnapEngine::scene32_updateHotspots() {
setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
setHotspot(kHSExitTruck, 780, 226, 800, 455, SF_EXIT_R_CURSOR | SF_WALKABLE, 10, 6);
setHotspot(kHSWalkArea1, 0, 0, 162, 426);
setHotspot(kHSWalkArea2, 162, 0, 237, 396);
setHotspot(kHSWalkArea3, 237, 0, 319, 363);
setHotspot(kHSWalkArea4, 520, 0, 800, 404);
setHotspot(kHSWalkArea5, 300, 447, 800, 600);
setHotspot(kHSWalkArea6, 678, 0, 800, 404);
setHotspot(kHSWalkArea7, 0, 0, 520, 351);
setHotspot(kHSWalkArea8, 0, 546, 300, 600);
setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
_hotspotsCount = 11;
}
void GnapEngine::scene32_run() {
playSound(0x1091C, true);
2014-01-07 20:37:29 +00:00
startSoundTimerC(5);
queueInsertDeviceIcon();
_timers[4] = getRandom(100) + 300;
if (_prevSceneNum == 33) {
initGnapPos(11, 6, kDirBottomLeft);
initBeaverPos(12, 6, kDirUnk4);
2014-01-07 20:37:29 +00:00
endSceneInit();
platypusWalkTo(9, 6, -1, 0x107D2, 1);
gnapWalkTo(8, 6, -1, 0x107BA, 1);
} else {
initGnapPos(1, 6, kDirBottomRight);
initBeaverPos(1, 7, kDirNone);
2014-01-07 20:37:29 +00:00
endSceneInit();
}
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
while (!_sceneDone) {
updateMouseCursor();
updateCursorByHotspot();
testWalk(0, 0, -1, -1, -1, -1);
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
_sceneClickedHotspot = getClickedHotspotId();
updateGrabCursorSprite(0, 0);
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
switch (_sceneClickedHotspot) {
case kHSDevice:
if (_gnapActionStatus < 0) {
runMenu();
scene32_updateHotspots();
}
break;
case kHSPlatypus:
if (_gnapActionStatus < 0) {
if (_grabCursorSpriteIndex >= 0) {
playGnapImpossible(_platX, _platY);
} else {
switch (_verbCursor) {
case LOOK_CURSOR:
playGnapMoan1(_platX, _platY);
break;
case GRAB_CURSOR:
gnapKissPlatypus(0);
break;
case TALK_CURSOR:
playGnapBrainPulsating(_platX, _platY);
2016-04-18 05:49:27 +00:00
playBeaverSequence(getBeaverSequenceId());
2014-01-07 20:37:29 +00:00
break;
case PLAT_CURSOR:
playGnapImpossible(_platX, _platY);
break;
}
}
}
break;
case kHSExitTruck:
if (_gnapActionStatus < 0) {
2014-01-23 11:51:43 +00:00
_isLeavingScene = true;
2014-01-07 20:37:29 +00:00
setGrabCursorSprite(-1);
gnapWalkTo(_hotspotsWalkPos[kHSExitTruck].x, _hotspotsWalkPos[kHSExitTruck].y, 0, 0x107AB, 1);
2014-01-23 11:51:43 +00:00
_gnapActionStatus = kASLeaveScene;
2014-01-07 20:37:29 +00:00
platypusWalkTo(_hotspotsWalkPos[kHSExitTruck].x, _hotspotsWalkPos[kHSExitTruck].y + 1, -1, 0x107CD, 1);
_newSceneNum = 33;
}
break;
case kHSWalkArea1:
case kHSWalkArea2:
case kHSWalkArea3:
case kHSWalkArea4:
case kHSWalkArea5:
case kHSWalkArea6:
case kHSWalkArea7:
case kHSWalkArea8:
if (_gnapActionStatus < 0)
gnapWalkTo(-1, -1, -1, -1, 1);
break;
}
if (_mouseClickState._left && _gnapActionStatus < 0) {
2014-01-07 20:37:29 +00:00
gnapWalkTo(-1, -1, -1, -1, 1);
_mouseClickState._left = 0;
2014-01-07 20:37:29 +00:00
}
scene32_updateAnimations();
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
if (!isSoundPlaying(0x1091C))
playSound(0x1091C, true);
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
if (!_isLeavingScene) {
if (_beaverActionStatus < 0)
updateBeaverIdleSequence();
if (_gnapActionStatus < 0)
updateGnapIdleSequence();
if (!_timers[4]) {
_timers[4] = getRandom(100) + 300;
if (getRandom(2) != 0)
2014-01-23 11:51:43 +00:00
_gameSys->insertSequence(0x0E, 180, 0, 0, kSeqNone, 0, 0, 0);
2014-01-07 20:37:29 +00:00
else
2014-01-23 11:51:43 +00:00
_gameSys->insertSequence(0x0D, 180, 0, 0, kSeqNone, 0, 0, 0);
2014-01-07 20:37:29 +00:00
}
playSoundC();
}
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
checkGameKeys();
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
if (isKeyStatus1(8)) {
clearKeyStatus1(8);
runMenu();
scene32_updateHotspots();
}
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
gameUpdateTick();
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
}
2016-04-12 11:48:48 +00:00
2014-01-07 20:37:29 +00:00
}
void GnapEngine::scene32_updateAnimations() {
if (_gameSys->getAnimationStatus(0) == 2) {
_gameSys->setAnimation(0, 0, 0);
2014-01-23 11:51:43 +00:00
if (_gnapActionStatus == kASLeaveScene)
2014-01-07 20:37:29 +00:00
_sceneDone = true;
}
}
} // End of namespace Gnap