mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-24 02:36:27 +00:00
NEVERHOOD: Split sprites from their scenes in modules 1700 and 1800
This also reduces inter-header dependencies
This commit is contained in:
parent
9715318932
commit
b963fcbfa8
@ -22,8 +22,10 @@ MODULE_OBJS = \
|
||||
modules/module1500.o \
|
||||
modules/module1600.o \
|
||||
modules/module1700.o \
|
||||
modules/module1700_sprites.o \
|
||||
modules/module1800.o \
|
||||
modules/module1900.o \
|
||||
modules/module1900_sprites.o \
|
||||
modules/module2000.o \
|
||||
modules/module2100.o \
|
||||
modules/module2100_sprites.o \
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "neverhood/modules/module1700.h"
|
||||
#include "neverhood/modules/module1700_sprites.h"
|
||||
#include "neverhood/gamemodule.h"
|
||||
|
||||
namespace Neverhood {
|
||||
@ -126,8 +127,6 @@ void Module1700::updateScene() {
|
||||
}
|
||||
}
|
||||
|
||||
// Scene1705
|
||||
|
||||
static const uint32 kScene1705FileHashes[] = {
|
||||
0x910EA801, 0x920EA801, 0x940EA801,
|
||||
0x980EA801, 0x800EA801, 0xB00EA801,
|
||||
@ -135,47 +134,6 @@ static const uint32 kScene1705FileHashes[] = {
|
||||
0xD10EA801, 0x110EA801, 0x910EA800
|
||||
};
|
||||
|
||||
SsScene1705WallSymbol::SsScene1705WallSymbol(NeverhoodEngine *vm, uint32 fileHash, int symbolIndex)
|
||||
: StaticSprite(vm, fileHash, 100) {
|
||||
|
||||
_x = _spriteResource.getPosition().x + symbolIndex * 30;
|
||||
_y = _spriteResource.getPosition().y + 160;
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
SsScene1705Tape::SsScene1705Tape(NeverhoodEngine *vm, Scene *parentScene, uint32 tapeIndex, int surfacePriority, int16 x, int16 y, uint32 fileHash)
|
||||
: StaticSprite(vm, fileHash, surfacePriority, x - 24, y - 4), _parentScene(parentScene), _tapeIndex(tapeIndex) {
|
||||
|
||||
if (!getSubVar(VA_HAS_TAPE, _tapeIndex) && !getSubVar(VA_IS_TAPE_INSERTED, _tapeIndex)) {
|
||||
SetMessageHandler(&SsScene1705Tape::handleMessage);
|
||||
} else {
|
||||
setVisible(false);
|
||||
SetMessageHandler(NULL);
|
||||
}
|
||||
_collisionBoundsOffset = _drawOffset;
|
||||
_collisionBoundsOffset.x -= 4;
|
||||
_collisionBoundsOffset.y -= 8;
|
||||
_collisionBoundsOffset.width += 8;
|
||||
_collisionBoundsOffset.height += 16;
|
||||
Sprite::updateBounds();
|
||||
}
|
||||
|
||||
uint32 SsScene1705Tape::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
sendMessage(_parentScene, 0x4826, 0);
|
||||
messageResult = 1;
|
||||
break;
|
||||
case 0x4806:
|
||||
setSubVar(VA_HAS_TAPE, _tapeIndex, 1);
|
||||
setVisible(false);
|
||||
SetMessageHandler(NULL);
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which)
|
||||
: Scene(vm, parentModule), _paletteArea(1) {
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "neverhood/neverhood.h"
|
||||
#include "neverhood/module.h"
|
||||
#include "neverhood/scene.h"
|
||||
#include "neverhood/smackerscene.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
@ -40,22 +39,6 @@ protected:
|
||||
void updateScene();
|
||||
};
|
||||
|
||||
// Scene1705
|
||||
|
||||
class SsScene1705WallSymbol : public StaticSprite {
|
||||
public:
|
||||
SsScene1705WallSymbol(NeverhoodEngine *vm, uint32 fileHash, int symbolIndex);
|
||||
};
|
||||
|
||||
class SsScene1705Tape : public StaticSprite {
|
||||
public:
|
||||
SsScene1705Tape(NeverhoodEngine *vm, Scene *parentScene, uint32 tapeIndex, int surfacePriority, int16 x, int16 y, uint32 fileHash);
|
||||
protected:
|
||||
Scene *_parentScene;
|
||||
uint32 _tapeIndex;
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
};
|
||||
|
||||
class Scene1705 : public Scene {
|
||||
public:
|
||||
Scene1705(NeverhoodEngine *vm, Module *parentModule, int which);
|
||||
|
69
engines/neverhood/modules/module1700_sprites.cpp
Normal file
69
engines/neverhood/modules/module1700_sprites.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/* 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 "neverhood/gamemodule.h"
|
||||
#include "neverhood/modules/module1700_sprites.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
SsScene1705WallSymbol::SsScene1705WallSymbol(NeverhoodEngine *vm, uint32 fileHash, int symbolIndex)
|
||||
: StaticSprite(vm, fileHash, 100) {
|
||||
|
||||
_x = _spriteResource.getPosition().x + symbolIndex * 30;
|
||||
_y = _spriteResource.getPosition().y + 160;
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
SsScene1705Tape::SsScene1705Tape(NeverhoodEngine *vm, Scene *parentScene, uint32 tapeIndex, int surfacePriority, int16 x, int16 y, uint32 fileHash)
|
||||
: StaticSprite(vm, fileHash, surfacePriority, x - 24, y - 4), _parentScene(parentScene), _tapeIndex(tapeIndex) {
|
||||
|
||||
if (!getSubVar(VA_HAS_TAPE, _tapeIndex) && !getSubVar(VA_IS_TAPE_INSERTED, _tapeIndex)) {
|
||||
SetMessageHandler(&SsScene1705Tape::handleMessage);
|
||||
} else {
|
||||
setVisible(false);
|
||||
SetMessageHandler(NULL);
|
||||
}
|
||||
_collisionBoundsOffset = _drawOffset;
|
||||
_collisionBoundsOffset.x -= 4;
|
||||
_collisionBoundsOffset.y -= 8;
|
||||
_collisionBoundsOffset.width += 8;
|
||||
_collisionBoundsOffset.height += 16;
|
||||
Sprite::updateBounds();
|
||||
}
|
||||
|
||||
uint32 SsScene1705Tape::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
sendMessage(_parentScene, 0x4826, 0);
|
||||
messageResult = 1;
|
||||
break;
|
||||
case 0x4806:
|
||||
setSubVar(VA_HAS_TAPE, _tapeIndex, 1);
|
||||
setVisible(false);
|
||||
SetMessageHandler(NULL);
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
} // End of namespace Neverhood
|
48
engines/neverhood/modules/module1700_sprites.h
Normal file
48
engines/neverhood/modules/module1700_sprites.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* 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 NEVERHOOD_MODULES_MODULE1700_SPRITES_H
|
||||
#define NEVERHOOD_MODULES_MODULE1700_SPRITES_H
|
||||
|
||||
#include "neverhood/neverhood.h"
|
||||
#include "neverhood/module.h"
|
||||
#include "neverhood/scene.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
class SsScene1705WallSymbol : public StaticSprite {
|
||||
public:
|
||||
SsScene1705WallSymbol(NeverhoodEngine *vm, uint32 fileHash, int symbolIndex);
|
||||
};
|
||||
|
||||
class SsScene1705Tape : public StaticSprite {
|
||||
public:
|
||||
SsScene1705Tape(NeverhoodEngine *vm, Scene *parentScene, uint32 tapeIndex, int surfacePriority, int16 x, int16 y, uint32 fileHash);
|
||||
protected:
|
||||
Scene *_parentScene;
|
||||
uint32 _tapeIndex;
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
};
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
||||
#endif /* NEVERHOOD_MODULES_MODULE1700_SPRITES_H */
|
@ -20,8 +20,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "neverhood/modules/module1900.h"
|
||||
#include "neverhood/gamemodule.h"
|
||||
#include "neverhood/modules/module1900.h"
|
||||
#include "neverhood/modules/module1900_sprites.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
@ -84,8 +85,6 @@ void Module1900::updateScene() {
|
||||
}
|
||||
}
|
||||
|
||||
// Scene1901
|
||||
|
||||
Scene1901::Scene1901(NeverhoodEngine *vm, Module *parentModule, int which)
|
||||
: Scene(vm, parentModule) {
|
||||
|
||||
@ -126,395 +125,6 @@ Scene1901::Scene1901(NeverhoodEngine *vm, Module *parentModule, int which)
|
||||
|
||||
}
|
||||
|
||||
static const NPoint kAsScene1907SymbolGroundPositions[] = {
|
||||
{160, 310}, { 90, 340}, {210, 335},
|
||||
{210, 380}, {310, 340}, {290, 400},
|
||||
{400, 375}, {370, 435}, {475, 415}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolPluggedInPositions[] = {
|
||||
{275, 125}, {244, 125}, {238, 131},
|
||||
{221, 135}, {199, 136}, {168, 149},
|
||||
{145, 152}, {123, 154}, {103, 157}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolGroundHitPositions[] = {
|
||||
{275, 299}, {244, 299}, {238, 305},
|
||||
{221, 309}, {199, 310}, {168, 323},
|
||||
{145, 326}, {123, 328}, {103, 331}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolPluggedInDownPositions[] = {
|
||||
{275, 136}, {244, 156}, {238, 183},
|
||||
{221, 207}, {199, 228}, {168, 262},
|
||||
{145, 285}, {123, 307}, {103, 331}
|
||||
};
|
||||
|
||||
static const uint32 kAsScene1907SymbolFileHashes[] = {
|
||||
0x006A1034, 0x006A1010, 0x006A1814,
|
||||
0x006A1016, 0x006A0014, 0x002A1014,
|
||||
0x00EA1014, 0x206A1014, 0x046A1414
|
||||
};
|
||||
|
||||
bool AsScene1907Symbol::_plugInFailed = false;
|
||||
int AsScene1907Symbol::_plugInTryCount = 0;
|
||||
|
||||
AsScene1907Symbol::AsScene1907Symbol(NeverhoodEngine *vm, Scene1907 *parentScene, int elementIndex, int positionIndex)
|
||||
: AnimatedSprite(vm, 1000 - positionIndex), _parentScene(parentScene), _elementIndex(elementIndex), _isMoving(false) {
|
||||
|
||||
_plugInFailed = false;
|
||||
_plugInTryCount = 0;
|
||||
|
||||
if (getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
_isPluggedIn = true;
|
||||
_currPositionIndex = elementIndex;
|
||||
if (!getGlobalVar(V_STAIRS_DOWN)) {
|
||||
_x = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].y;
|
||||
} else {
|
||||
_x = kAsScene1907SymbolPluggedInDownPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInDownPositions[_currPositionIndex].y;
|
||||
}
|
||||
createSurface1(kAsScene1907SymbolFileHashes[_elementIndex], 1000 + _currPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
_newStickFrameIndex = STICK_LAST_FRAME;
|
||||
} else {
|
||||
_isPluggedIn = false;
|
||||
_currPositionIndex = positionIndex;
|
||||
loadSound(0, 0x74231924);
|
||||
loadSound(1, 0x36691914);
|
||||
loadSound(2, 0x5421D806);
|
||||
_parentScene->setPositionFree(_currPositionIndex, false);
|
||||
_x = kAsScene1907SymbolGroundPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolGroundPositions[_currPositionIndex].y;
|
||||
createSurface1(kAsScene1907SymbolFileHashes[_elementIndex], 1000 + _currPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
}
|
||||
_collisionBoundsOffset.set(0, 0, 80, 80);
|
||||
Sprite::updateBounds();
|
||||
SetUpdateHandler(&AnimatedSprite::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::update() {
|
||||
updateAnim();
|
||||
handleSpriteUpdate();
|
||||
updatePosition();
|
||||
if (_plugInFailed && _plugInTryCount == 0)
|
||||
_plugInFailed = false;
|
||||
}
|
||||
|
||||
uint32 AsScene1907Symbol::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
if (!_isPluggedIn && !_plugInFailed) {
|
||||
tryToPlugIn();
|
||||
messageResult = 1;
|
||||
} else
|
||||
messageResult = 0;
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
uint32 AsScene1907Symbol::hmTryToPlugIn(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x3002:
|
||||
gotoNextState();
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suTryToPlugIn() {
|
||||
_currStep++;
|
||||
_x -= _deltaX;
|
||||
_y -= _deltaY;
|
||||
if (_currStep == 16) {
|
||||
_x -= _smallDeltaX;
|
||||
_y -= _smallDeltaY;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suFallOff() {
|
||||
if (_fallOffDelay != 0) {
|
||||
_fallOffDelay--;
|
||||
} else {
|
||||
_y += _yAccel;
|
||||
_yAccel += 8;
|
||||
if (_y >= kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y) {
|
||||
_y = kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y;
|
||||
stFallOffHitGround();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suFallOffHitGround() {
|
||||
|
||||
if (_x == _someX - _xBreak)
|
||||
_x -= _smallDeltaX;
|
||||
else
|
||||
_x -= _deltaX;
|
||||
|
||||
if (_y == kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y) {
|
||||
_y -= _someY;
|
||||
}
|
||||
|
||||
if (_currStep < 8) {
|
||||
_y -= _yAccel;
|
||||
_yAccel -= 4;
|
||||
if (_yAccel < 0)
|
||||
_yAccel = 0;
|
||||
} else if (_currStep < 15) {
|
||||
_y += _yAccel;
|
||||
_yAccel += 4;
|
||||
} else {
|
||||
_y = kAsScene1907SymbolGroundPositions[_newPositionIndex].y;
|
||||
cbFallOffHitGroundEvent();
|
||||
}
|
||||
|
||||
_currStep++;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suMoveDown() {
|
||||
_y += _yIncr;
|
||||
if (_yIncr < 11)
|
||||
_yIncr++;
|
||||
if (_y >= kAsScene1907SymbolPluggedInDownPositions[_elementIndex].y) {
|
||||
_y = kAsScene1907SymbolPluggedInDownPositions[_elementIndex].y;
|
||||
_isMoving = false;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suMoveUp() {
|
||||
_y -= _yIncr;
|
||||
if (getGlobalVar(V_WALL_BROKEN)) {
|
||||
if (_y - (9 + (_elementIndex > 5 ? 31 : 0)) < kAsScene1907SymbolPluggedInPositions[_elementIndex].y)
|
||||
_yIncr--;
|
||||
else
|
||||
_yIncr++;
|
||||
} else
|
||||
_yIncr = 2;
|
||||
if (_yIncr > 9)
|
||||
_yIncr = 9;
|
||||
else if (_yIncr < 1)
|
||||
_yIncr = 1;
|
||||
if (_y < kAsScene1907SymbolPluggedInPositions[_elementIndex].y) {
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_elementIndex].y;
|
||||
_isMoving = false;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::tryToPlugIn() {
|
||||
_isPluggedIn = true;
|
||||
_plugInTryCount++;
|
||||
_newPositionIndex = _parentScene->getNextPosition();
|
||||
_parentScene->setPositionFree(_currPositionIndex, true);
|
||||
sendMessage(_parentScene, 0x1022, 1100 + _newPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
SetUpdateHandler(&AsScene1907Symbol::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::hmTryToPlugIn);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suTryToPlugIn);
|
||||
_currStep = 0;
|
||||
_deltaX = (_x - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].x) / 16;
|
||||
_smallDeltaX = _x - _deltaX * 16 - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].x;
|
||||
_deltaY = (_y - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].y) / 16;
|
||||
_smallDeltaY = _y - _deltaY * 16 - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].y;
|
||||
if (_elementIndex == _newPositionIndex) {
|
||||
NextState(&AsScene1907Symbol::stPlugIn);
|
||||
} else {
|
||||
_plugInFailed = true;
|
||||
NextState(&AsScene1907Symbol::stPlugInFail);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::fallOff(int newPositionIndex, int fallOffDelay) {
|
||||
_isPluggedIn = false;
|
||||
_newPositionIndex = newPositionIndex;
|
||||
_fallOffDelay = fallOffDelay;
|
||||
_parentScene->setPositionFree(_newPositionIndex, false);
|
||||
_x = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].y;
|
||||
_someX = _x;
|
||||
_someY = _y;
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, 0);
|
||||
_playBackwards = true;
|
||||
_newStickFrameIndex = STICK_LAST_FRAME;
|
||||
_currStep = 0;
|
||||
_yAccel = 1;
|
||||
SetUpdateHandler(&AsScene1907Symbol::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suFallOff);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stFallOffHitGround() {
|
||||
playSound(1);
|
||||
sendMessage(_parentScene, 0x1022, 1000 + _newPositionIndex);
|
||||
Entity::_priority = 1000 - _newPositionIndex;
|
||||
_parentScene->removeCollisionSprite(this);
|
||||
_parentScene->addCollisionSprite(this);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suFallOffHitGround);
|
||||
NextState(&AsScene1907Symbol::cbFallOffHitGroundEvent);
|
||||
_newStickFrameIndex = 0;
|
||||
_currStep = 0;
|
||||
_yAccel = 30;
|
||||
_deltaX = (_x - kAsScene1907SymbolGroundPositions[_newPositionIndex].x) / 15;
|
||||
_xBreak = _deltaX * 15;
|
||||
_smallDeltaX = _x - kAsScene1907SymbolGroundPositions[_newPositionIndex].x - _xBreak;
|
||||
_someY = 0;
|
||||
if (kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y > kAsScene1907SymbolGroundPositions[_newPositionIndex].y)
|
||||
_someY = kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y - kAsScene1907SymbolGroundPositions[_newPositionIndex].y;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::cbFallOffHitGroundEvent() {
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
if (_plugInTryCount > 0)
|
||||
_plugInTryCount--;
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
SetUpdateHandler(&AnimatedSprite::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(NULL);
|
||||
updateBounds();
|
||||
playSound(2);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stPlugIn() {
|
||||
playSound(0);
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(NULL);
|
||||
if (_elementIndex == 8)
|
||||
sendMessage(_parentScene, 0x2001, 0);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stPlugInFail() {
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
stopAnimation();
|
||||
_parentScene->plugInFailed();
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::moveUp() {
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suMoveUp);
|
||||
_yIncr = 1;
|
||||
_isMoving = true;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::moveDown() {
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suMoveDown);
|
||||
_yIncr = 4;
|
||||
_isMoving = true;
|
||||
}
|
||||
|
||||
SsScene1907UpDownButton::SsScene1907UpDownButton(NeverhoodEngine *vm, Scene1907 *parentScene, AsScene1907Symbol *asScene1907Symbol)
|
||||
: StaticSprite(vm, 1400), _parentScene(parentScene), _asScene1907Symbol(asScene1907Symbol),
|
||||
_countdown1(0) {
|
||||
|
||||
loadSprite(0x64516424, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 1400);
|
||||
setVisible(false);
|
||||
loadSound(0, 0x44061000);
|
||||
SetUpdateHandler(&SsScene1907UpDownButton::update);
|
||||
SetMessageHandler(&SsScene1907UpDownButton::handleMessage);
|
||||
if (getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
if (getGlobalVar(V_STAIRS_DOWN))
|
||||
setToDownPosition();
|
||||
else
|
||||
setToUpPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::update() {
|
||||
updatePosition();
|
||||
if (_countdown1 != 0 && (--_countdown1 == 0)) {
|
||||
setVisible(false);
|
||||
sendMessage(_parentScene, 0x2000, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 SsScene1907UpDownButton::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
if (_countdown1 == 0 && !_asScene1907Symbol->isMoving() && getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
setVisible(true);
|
||||
_countdown1 = 4;
|
||||
updatePosition();
|
||||
playSound(0);
|
||||
}
|
||||
messageResult = 1;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::setToUpPosition() {
|
||||
_y = _spriteResource.getPosition().y;
|
||||
updateBounds();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::setToDownPosition() {
|
||||
_y = _spriteResource.getPosition().y + 174;
|
||||
updateBounds();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
AsScene1907WaterHint::AsScene1907WaterHint(NeverhoodEngine *vm)
|
||||
: AnimatedSprite(vm, 1400) {
|
||||
|
||||
createSurface1(0x110A1061, 1500);
|
||||
_x = 320;
|
||||
_y = 240;
|
||||
startAnimation(0x110A1061, 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
setVisible(false);
|
||||
_needRefresh = true;
|
||||
AnimatedSprite::updatePosition();
|
||||
SetUpdateHandler(&AsScene1907WaterHint::update);
|
||||
SetMessageHandler(&Sprite::handleMessage);
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::update() {
|
||||
updateAnim();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
uint32 AsScene1907WaterHint::hmShowing(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x3002:
|
||||
gotoNextState();
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::show() {
|
||||
setVisible(true);
|
||||
startAnimation(0x110A1061, 0, -1);
|
||||
SetMessageHandler(&AsScene1907WaterHint::hmShowing);
|
||||
NextState(&AsScene1907WaterHint::hide);
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::hide() {
|
||||
stopAnimation();
|
||||
setVisible(false);
|
||||
SetMessageHandler(&Sprite::handleMessage);
|
||||
}
|
||||
|
||||
Scene1907::Scene1907(NeverhoodEngine *vm, Module *parentModule)
|
||||
: Scene(vm, parentModule), _currMovingSymbolIndex(0), _pluggedInCount(0),
|
||||
_moveDownCountdown(0), _moveUpCountdown(0), _countdown3(0), _hasPlugInFailed(false) {
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "neverhood/neverhood.h"
|
||||
#include "neverhood/module.h"
|
||||
#include "neverhood/scene.h"
|
||||
#include "neverhood/modules/module1200.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
@ -41,80 +40,14 @@ protected:
|
||||
void updateScene();
|
||||
};
|
||||
|
||||
// Scene1901
|
||||
|
||||
class Scene1901 : public Scene {
|
||||
public:
|
||||
Scene1901(NeverhoodEngine *vm, Module *parentModule, int which);
|
||||
};
|
||||
|
||||
// Scene1907
|
||||
|
||||
class Scene1907;
|
||||
|
||||
class AsScene1907Symbol : public AnimatedSprite {
|
||||
public:
|
||||
AsScene1907Symbol(NeverhoodEngine *vm, Scene1907 *parentScene, int elementIndex, int positionIndex);
|
||||
void moveUp();
|
||||
void moveDown();
|
||||
void fallOff(int newPositionIndex, int fallOffDelay);
|
||||
bool isPluggedIn() { return _isPluggedIn; }
|
||||
bool isMoving() { return _isMoving; }
|
||||
protected:
|
||||
Scene1907 *_parentScene;
|
||||
int _elementIndex;
|
||||
int _currPositionIndex;
|
||||
int _newPositionIndex;
|
||||
bool _isPluggedIn;
|
||||
bool _isMoving;
|
||||
int _someX, _someY;
|
||||
int _xBreak;
|
||||
int _currStep;
|
||||
int _yAccel;
|
||||
int _yIncr;
|
||||
int _fallOffDelay;
|
||||
int _deltaX, _smallDeltaX;
|
||||
int _deltaY, _smallDeltaY;
|
||||
// Dumb, change if possible
|
||||
static bool _plugInFailed;
|
||||
static int _plugInTryCount;
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
uint32 hmTryToPlugIn(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void suTryToPlugIn();
|
||||
void suFallOff();
|
||||
void suFallOffHitGround();
|
||||
void suMoveDown();
|
||||
void suMoveUp();
|
||||
void tryToPlugIn();
|
||||
void stFallOffHitGround();
|
||||
void cbFallOffHitGroundEvent();
|
||||
void stPlugIn();
|
||||
void stPlugInFail();
|
||||
};
|
||||
|
||||
class AsScene1907WaterHint : public AnimatedSprite {
|
||||
public:
|
||||
AsScene1907WaterHint(NeverhoodEngine *vm);
|
||||
void show();
|
||||
protected:
|
||||
void update();
|
||||
uint32 hmShowing(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void hide();
|
||||
};
|
||||
|
||||
class SsScene1907UpDownButton : public StaticSprite {
|
||||
public:
|
||||
SsScene1907UpDownButton(NeverhoodEngine *vm, Scene1907 *parentScene, AsScene1907Symbol *asScene1907Symbol);
|
||||
void setToUpPosition();
|
||||
void setToDownPosition();
|
||||
protected:
|
||||
Scene1907 *_parentScene;
|
||||
AsScene1907Symbol *_asScene1907Symbol;
|
||||
int _countdown1;
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
};
|
||||
class AsScene1907Symbol;
|
||||
class SsScene1907UpDownButton;
|
||||
class AsScene1907WaterHint;
|
||||
|
||||
class Scene1907 : public Scene {
|
||||
public:
|
||||
|
418
engines/neverhood/modules/module1900_sprites.cpp
Normal file
418
engines/neverhood/modules/module1900_sprites.cpp
Normal file
@ -0,0 +1,418 @@
|
||||
/* 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 "neverhood/gamemodule.h"
|
||||
#include "neverhood/modules/module1900.h"
|
||||
#include "neverhood/modules/module1900_sprites.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
static const NPoint kAsScene1907SymbolGroundPositions[] = {
|
||||
{160, 310}, { 90, 340}, {210, 335},
|
||||
{210, 380}, {310, 340}, {290, 400},
|
||||
{400, 375}, {370, 435}, {475, 415}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolPluggedInPositions[] = {
|
||||
{275, 125}, {244, 125}, {238, 131},
|
||||
{221, 135}, {199, 136}, {168, 149},
|
||||
{145, 152}, {123, 154}, {103, 157}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolGroundHitPositions[] = {
|
||||
{275, 299}, {244, 299}, {238, 305},
|
||||
{221, 309}, {199, 310}, {168, 323},
|
||||
{145, 326}, {123, 328}, {103, 331}
|
||||
};
|
||||
|
||||
static const NPoint kAsScene1907SymbolPluggedInDownPositions[] = {
|
||||
{275, 136}, {244, 156}, {238, 183},
|
||||
{221, 207}, {199, 228}, {168, 262},
|
||||
{145, 285}, {123, 307}, {103, 331}
|
||||
};
|
||||
|
||||
static const uint32 kAsScene1907SymbolFileHashes[] = {
|
||||
0x006A1034, 0x006A1010, 0x006A1814,
|
||||
0x006A1016, 0x006A0014, 0x002A1014,
|
||||
0x00EA1014, 0x206A1014, 0x046A1414
|
||||
};
|
||||
|
||||
bool AsScene1907Symbol::_plugInFailed = false;
|
||||
int AsScene1907Symbol::_plugInTryCount = 0;
|
||||
|
||||
AsScene1907Symbol::AsScene1907Symbol(NeverhoodEngine *vm, Scene1907 *parentScene, int elementIndex, int positionIndex)
|
||||
: AnimatedSprite(vm, 1000 - positionIndex), _parentScene(parentScene), _elementIndex(elementIndex), _isMoving(false) {
|
||||
|
||||
_plugInFailed = false;
|
||||
_plugInTryCount = 0;
|
||||
|
||||
if (getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
_isPluggedIn = true;
|
||||
_currPositionIndex = elementIndex;
|
||||
if (!getGlobalVar(V_STAIRS_DOWN)) {
|
||||
_x = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].y;
|
||||
} else {
|
||||
_x = kAsScene1907SymbolPluggedInDownPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInDownPositions[_currPositionIndex].y;
|
||||
}
|
||||
createSurface1(kAsScene1907SymbolFileHashes[_elementIndex], 1000 + _currPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
_newStickFrameIndex = STICK_LAST_FRAME;
|
||||
} else {
|
||||
_isPluggedIn = false;
|
||||
_currPositionIndex = positionIndex;
|
||||
loadSound(0, 0x74231924);
|
||||
loadSound(1, 0x36691914);
|
||||
loadSound(2, 0x5421D806);
|
||||
_parentScene->setPositionFree(_currPositionIndex, false);
|
||||
_x = kAsScene1907SymbolGroundPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolGroundPositions[_currPositionIndex].y;
|
||||
createSurface1(kAsScene1907SymbolFileHashes[_elementIndex], 1000 + _currPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
}
|
||||
_collisionBoundsOffset.set(0, 0, 80, 80);
|
||||
Sprite::updateBounds();
|
||||
SetUpdateHandler(&AnimatedSprite::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::update() {
|
||||
updateAnim();
|
||||
handleSpriteUpdate();
|
||||
updatePosition();
|
||||
if (_plugInFailed && _plugInTryCount == 0)
|
||||
_plugInFailed = false;
|
||||
}
|
||||
|
||||
uint32 AsScene1907Symbol::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
if (!_isPluggedIn && !_plugInFailed) {
|
||||
tryToPlugIn();
|
||||
messageResult = 1;
|
||||
} else
|
||||
messageResult = 0;
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
uint32 AsScene1907Symbol::hmTryToPlugIn(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x3002:
|
||||
gotoNextState();
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suTryToPlugIn() {
|
||||
_currStep++;
|
||||
_x -= _deltaX;
|
||||
_y -= _deltaY;
|
||||
if (_currStep == 16) {
|
||||
_x -= _smallDeltaX;
|
||||
_y -= _smallDeltaY;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suFallOff() {
|
||||
if (_fallOffDelay != 0) {
|
||||
_fallOffDelay--;
|
||||
} else {
|
||||
_y += _yAccel;
|
||||
_yAccel += 8;
|
||||
if (_y >= kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y) {
|
||||
_y = kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y;
|
||||
stFallOffHitGround();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suFallOffHitGround() {
|
||||
|
||||
if (_x == _someX - _xBreak)
|
||||
_x -= _smallDeltaX;
|
||||
else
|
||||
_x -= _deltaX;
|
||||
|
||||
if (_y == kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y) {
|
||||
_y -= _someY;
|
||||
}
|
||||
|
||||
if (_currStep < 8) {
|
||||
_y -= _yAccel;
|
||||
_yAccel -= 4;
|
||||
if (_yAccel < 0)
|
||||
_yAccel = 0;
|
||||
} else if (_currStep < 15) {
|
||||
_y += _yAccel;
|
||||
_yAccel += 4;
|
||||
} else {
|
||||
_y = kAsScene1907SymbolGroundPositions[_newPositionIndex].y;
|
||||
cbFallOffHitGroundEvent();
|
||||
}
|
||||
|
||||
_currStep++;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suMoveDown() {
|
||||
_y += _yIncr;
|
||||
if (_yIncr < 11)
|
||||
_yIncr++;
|
||||
if (_y >= kAsScene1907SymbolPluggedInDownPositions[_elementIndex].y) {
|
||||
_y = kAsScene1907SymbolPluggedInDownPositions[_elementIndex].y;
|
||||
_isMoving = false;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::suMoveUp() {
|
||||
_y -= _yIncr;
|
||||
if (getGlobalVar(V_WALL_BROKEN)) {
|
||||
if (_y - (9 + (_elementIndex > 5 ? 31 : 0)) < kAsScene1907SymbolPluggedInPositions[_elementIndex].y)
|
||||
_yIncr--;
|
||||
else
|
||||
_yIncr++;
|
||||
} else
|
||||
_yIncr = 2;
|
||||
if (_yIncr > 9)
|
||||
_yIncr = 9;
|
||||
else if (_yIncr < 1)
|
||||
_yIncr = 1;
|
||||
if (_y < kAsScene1907SymbolPluggedInPositions[_elementIndex].y) {
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_elementIndex].y;
|
||||
_isMoving = false;
|
||||
SetSpriteUpdate(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::tryToPlugIn() {
|
||||
_isPluggedIn = true;
|
||||
_plugInTryCount++;
|
||||
_newPositionIndex = _parentScene->getNextPosition();
|
||||
_parentScene->setPositionFree(_currPositionIndex, true);
|
||||
sendMessage(_parentScene, 0x1022, 1100 + _newPositionIndex);
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
SetUpdateHandler(&AsScene1907Symbol::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::hmTryToPlugIn);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suTryToPlugIn);
|
||||
_currStep = 0;
|
||||
_deltaX = (_x - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].x) / 16;
|
||||
_smallDeltaX = _x - _deltaX * 16 - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].x;
|
||||
_deltaY = (_y - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].y) / 16;
|
||||
_smallDeltaY = _y - _deltaY * 16 - kAsScene1907SymbolPluggedInPositions[_newPositionIndex].y;
|
||||
if (_elementIndex == _newPositionIndex) {
|
||||
NextState(&AsScene1907Symbol::stPlugIn);
|
||||
} else {
|
||||
_plugInFailed = true;
|
||||
NextState(&AsScene1907Symbol::stPlugInFail);
|
||||
}
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::fallOff(int newPositionIndex, int fallOffDelay) {
|
||||
_isPluggedIn = false;
|
||||
_newPositionIndex = newPositionIndex;
|
||||
_fallOffDelay = fallOffDelay;
|
||||
_parentScene->setPositionFree(_newPositionIndex, false);
|
||||
_x = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].x;
|
||||
_y = kAsScene1907SymbolPluggedInPositions[_currPositionIndex].y;
|
||||
_someX = _x;
|
||||
_someY = _y;
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, 0);
|
||||
_playBackwards = true;
|
||||
_newStickFrameIndex = STICK_LAST_FRAME;
|
||||
_currStep = 0;
|
||||
_yAccel = 1;
|
||||
SetUpdateHandler(&AsScene1907Symbol::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suFallOff);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stFallOffHitGround() {
|
||||
playSound(1);
|
||||
sendMessage(_parentScene, 0x1022, 1000 + _newPositionIndex);
|
||||
Entity::_priority = 1000 - _newPositionIndex;
|
||||
_parentScene->removeCollisionSprite(this);
|
||||
_parentScene->addCollisionSprite(this);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suFallOffHitGround);
|
||||
NextState(&AsScene1907Symbol::cbFallOffHitGroundEvent);
|
||||
_newStickFrameIndex = 0;
|
||||
_currStep = 0;
|
||||
_yAccel = 30;
|
||||
_deltaX = (_x - kAsScene1907SymbolGroundPositions[_newPositionIndex].x) / 15;
|
||||
_xBreak = _deltaX * 15;
|
||||
_smallDeltaX = _x - kAsScene1907SymbolGroundPositions[_newPositionIndex].x - _xBreak;
|
||||
_someY = 0;
|
||||
if (kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y > kAsScene1907SymbolGroundPositions[_newPositionIndex].y)
|
||||
_someY = kAsScene1907SymbolGroundHitPositions[_currPositionIndex].y - kAsScene1907SymbolGroundPositions[_newPositionIndex].y;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::cbFallOffHitGroundEvent() {
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
if (_plugInTryCount > 0)
|
||||
_plugInTryCount--;
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
SetUpdateHandler(&AnimatedSprite::update);
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(NULL);
|
||||
updateBounds();
|
||||
playSound(2);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stPlugIn() {
|
||||
playSound(0);
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(NULL);
|
||||
if (_elementIndex == 8)
|
||||
sendMessage(_parentScene, 0x2001, 0);
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::stPlugInFail() {
|
||||
_currPositionIndex = _newPositionIndex;
|
||||
stopAnimation();
|
||||
_parentScene->plugInFailed();
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::moveUp() {
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suMoveUp);
|
||||
_yIncr = 1;
|
||||
_isMoving = true;
|
||||
}
|
||||
|
||||
void AsScene1907Symbol::moveDown() {
|
||||
startAnimation(kAsScene1907SymbolFileHashes[_elementIndex], -1, -1);
|
||||
stopAnimation();
|
||||
SetMessageHandler(&AsScene1907Symbol::handleMessage);
|
||||
SetSpriteUpdate(&AsScene1907Symbol::suMoveDown);
|
||||
_yIncr = 4;
|
||||
_isMoving = true;
|
||||
}
|
||||
|
||||
SsScene1907UpDownButton::SsScene1907UpDownButton(NeverhoodEngine *vm, Scene1907 *parentScene, AsScene1907Symbol *asScene1907Symbol)
|
||||
: StaticSprite(vm, 1400), _parentScene(parentScene), _asScene1907Symbol(asScene1907Symbol),
|
||||
_countdown1(0) {
|
||||
|
||||
loadSprite(0x64516424, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 1400);
|
||||
setVisible(false);
|
||||
loadSound(0, 0x44061000);
|
||||
SetUpdateHandler(&SsScene1907UpDownButton::update);
|
||||
SetMessageHandler(&SsScene1907UpDownButton::handleMessage);
|
||||
if (getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
if (getGlobalVar(V_STAIRS_DOWN))
|
||||
setToDownPosition();
|
||||
else
|
||||
setToUpPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::update() {
|
||||
updatePosition();
|
||||
if (_countdown1 != 0 && (--_countdown1 == 0)) {
|
||||
setVisible(false);
|
||||
sendMessage(_parentScene, 0x2000, 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 SsScene1907UpDownButton::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x1011:
|
||||
if (_countdown1 == 0 && !_asScene1907Symbol->isMoving() && getGlobalVar(V_STAIRS_PUZZLE_SOLVED)) {
|
||||
setVisible(true);
|
||||
_countdown1 = 4;
|
||||
updatePosition();
|
||||
playSound(0);
|
||||
}
|
||||
messageResult = 1;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::setToUpPosition() {
|
||||
_y = _spriteResource.getPosition().y;
|
||||
updateBounds();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
void SsScene1907UpDownButton::setToDownPosition() {
|
||||
_y = _spriteResource.getPosition().y + 174;
|
||||
updateBounds();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
AsScene1907WaterHint::AsScene1907WaterHint(NeverhoodEngine *vm)
|
||||
: AnimatedSprite(vm, 1400) {
|
||||
|
||||
createSurface1(0x110A1061, 1500);
|
||||
_x = 320;
|
||||
_y = 240;
|
||||
startAnimation(0x110A1061, 0, -1);
|
||||
_newStickFrameIndex = 0;
|
||||
setVisible(false);
|
||||
_needRefresh = true;
|
||||
AnimatedSprite::updatePosition();
|
||||
SetUpdateHandler(&AsScene1907WaterHint::update);
|
||||
SetMessageHandler(&Sprite::handleMessage);
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::update() {
|
||||
updateAnim();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
uint32 AsScene1907WaterHint::hmShowing(int messageNum, const MessageParam ¶m, Entity *sender) {
|
||||
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
|
||||
switch (messageNum) {
|
||||
case 0x3002:
|
||||
gotoNextState();
|
||||
break;
|
||||
}
|
||||
return messageResult;
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::show() {
|
||||
setVisible(true);
|
||||
startAnimation(0x110A1061, 0, -1);
|
||||
SetMessageHandler(&AsScene1907WaterHint::hmShowing);
|
||||
NextState(&AsScene1907WaterHint::hide);
|
||||
}
|
||||
|
||||
void AsScene1907WaterHint::hide() {
|
||||
stopAnimation();
|
||||
setVisible(false);
|
||||
SetMessageHandler(&Sprite::handleMessage);
|
||||
}
|
||||
|
||||
} // End of namespace Neverhood
|
100
engines/neverhood/modules/module1900_sprites.h
Normal file
100
engines/neverhood/modules/module1900_sprites.h
Normal file
@ -0,0 +1,100 @@
|
||||
/* 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 NEVERHOOD_MODULES_MODULE1900_SPRITES_H
|
||||
#define NEVERHOOD_MODULES_MODULE1900_SPRITES_H
|
||||
|
||||
#include "neverhood/neverhood.h"
|
||||
#include "neverhood/module.h"
|
||||
#include "neverhood/scene.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
class Scene1907;
|
||||
|
||||
class AsScene1907Symbol : public AnimatedSprite {
|
||||
public:
|
||||
AsScene1907Symbol(NeverhoodEngine *vm, Scene1907 *parentScene, int elementIndex, int positionIndex);
|
||||
void moveUp();
|
||||
void moveDown();
|
||||
void fallOff(int newPositionIndex, int fallOffDelay);
|
||||
bool isPluggedIn() { return _isPluggedIn; }
|
||||
bool isMoving() { return _isMoving; }
|
||||
protected:
|
||||
Scene1907 *_parentScene;
|
||||
int _elementIndex;
|
||||
int _currPositionIndex;
|
||||
int _newPositionIndex;
|
||||
bool _isPluggedIn;
|
||||
bool _isMoving;
|
||||
int _someX, _someY;
|
||||
int _xBreak;
|
||||
int _currStep;
|
||||
int _yAccel;
|
||||
int _yIncr;
|
||||
int _fallOffDelay;
|
||||
int _deltaX, _smallDeltaX;
|
||||
int _deltaY, _smallDeltaY;
|
||||
// Dumb, change if possible
|
||||
static bool _plugInFailed;
|
||||
static int _plugInTryCount;
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
uint32 hmTryToPlugIn(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void suTryToPlugIn();
|
||||
void suFallOff();
|
||||
void suFallOffHitGround();
|
||||
void suMoveDown();
|
||||
void suMoveUp();
|
||||
void tryToPlugIn();
|
||||
void stFallOffHitGround();
|
||||
void cbFallOffHitGroundEvent();
|
||||
void stPlugIn();
|
||||
void stPlugInFail();
|
||||
};
|
||||
|
||||
class AsScene1907WaterHint : public AnimatedSprite {
|
||||
public:
|
||||
AsScene1907WaterHint(NeverhoodEngine *vm);
|
||||
void show();
|
||||
protected:
|
||||
void update();
|
||||
uint32 hmShowing(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
void hide();
|
||||
};
|
||||
|
||||
class SsScene1907UpDownButton : public StaticSprite {
|
||||
public:
|
||||
SsScene1907UpDownButton(NeverhoodEngine *vm, Scene1907 *parentScene, AsScene1907Symbol *asScene1907Symbol);
|
||||
void setToUpPosition();
|
||||
void setToDownPosition();
|
||||
protected:
|
||||
Scene1907 *_parentScene;
|
||||
AsScene1907Symbol *_asScene1907Symbol;
|
||||
int _countdown1;
|
||||
void update();
|
||||
uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender);
|
||||
};
|
||||
|
||||
} // End of namespace Neverhood
|
||||
|
||||
#endif /* NEVERHOOD_MODULES_MODULE1900_SPRITES_H */
|
@ -26,7 +26,6 @@
|
||||
#include "neverhood/neverhood.h"
|
||||
#include "neverhood/module.h"
|
||||
#include "neverhood/scene.h"
|
||||
#include "neverhood/modules/module1200.h"
|
||||
|
||||
namespace Neverhood {
|
||||
|
||||
@ -41,8 +40,6 @@ protected:
|
||||
void updateScene();
|
||||
};
|
||||
|
||||
// Scene2001
|
||||
|
||||
class Scene2001 : public Scene {
|
||||
public:
|
||||
Scene2001(NeverhoodEngine *vm, Module *parentModule, int which);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "neverhood/gamemodule.h"
|
||||
#include "neverhood/modules/module1000.h"
|
||||
#include "neverhood/modules/module1200.h"
|
||||
#include "neverhood/modules/module1700.h"
|
||||
#include "neverhood/modules/module1700_sprites.h"
|
||||
#include "neverhood/modules/module2200_sprites.h"
|
||||
#include "neverhood/modules/module2800_sprites.h"
|
||||
#include "neverhood/diskplayerscene.h"
|
||||
|
Loading…
Reference in New Issue
Block a user