scummvm/engines/prince/hero.cpp

812 lines
19 KiB
C++
Raw Normal View History

/* 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.
*
*/
2013-12-05 00:02:31 +00:00
#include "common/debug.h"
#include "common/random.h"
#include "prince/hero.h"
2013-12-05 00:02:31 +00:00
#include "prince/hero_set.h"
#include "prince/animation.h"
#include "prince/resource.h"
2014-05-04 16:02:53 +00:00
#include "prince/prince.h"
2014-05-11 11:57:52 +00:00
#include "prince/graphics.h"
namespace Prince {
2014-05-11 11:57:52 +00:00
Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph)
, _number(0), _visible(false), _state(MOVE), _middleX(0), _middleY(0)
, _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0)
, _lastDirection(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0)
, _specAnim(0), _drawX(0), _drawY(0), _randomSource("prince"), _zoomFactor(0), _scaleValue(0)
2014-05-11 11:57:52 +00:00
, _shadZoomFactor(0), _shadScaleValue(0), _shadowLineLen(0), _shadowDrawX(0), _shadowDrawY(0)
, _shadLastY(0)
{
_zoomBitmap = new Animation();
_shadowBitmap = new Animation();
_shadowLine = new byte[kShadowLineArraySize];
}
2013-12-05 00:02:31 +00:00
Hero::~Hero() {
delete _zoomBitmap;
delete _shadowBitmap;
delete[] _shadowLine;
}
2013-12-05 00:02:31 +00:00
bool Hero::loadAnimSet(uint32 animSetNr) {
if (animSetNr > sizeof(heroSetTable)) {
return false;
}
_shadMinus = heroSetBack[animSetNr];
2013-12-05 00:02:31 +00:00
for (uint32 i = 0; i < _moveSet.size(); ++i) {
delete _moveSet[i];
}
const HeroSetAnimNames &animSet = *heroSetTable[animSetNr];
_moveSet.resize(kMoveSetSize);
for (uint32 i = 0; i < kMoveSetSize; ++i) {
debug("Anim set item %d %s", i, animSet[i]);
Animation *anim = NULL;
if (animSet[i] != NULL) {
anim = new Animation();
Resource::loadResource(anim, animSet[i]);
}
_moveSet[i] = anim;
}
return true;
}
const Graphics::Surface * Hero::getSurface() {
2014-04-01 23:35:07 +00:00
if (_moveSet[_moveSetType]) {
2014-04-28 10:15:54 +00:00
debug("BaseX: %d", _moveSet[_moveSetType]->getBaseX());
debug("BaseY: %d", _moveSet[_moveSetType]->getBaseY());
//debug("FrameCount: %d", _moveSet[_moveSetType]->getFrameCount());
//debug("LoopCount: %d", _moveSet[_moveSetType]->getLoopCount());
//debug("PhaseCount: %d", _moveSet[_moveSetType]->getPhaseCount());
//debug("PhaseFrameIndex(%d): %d", _frame, _moveSet[_moveSetType]->getPhaseFrameIndex(_frame));
//debug("PhaseOffsetX(%d): %d", _frame, _moveSet[_moveSetType]->getPhaseOffsetX(_frame));
//debug("PhaseOffsetY(%d) %d", _frame, _moveSet[_moveSetType]->getPhaseOffsetY(_frame));
//debug("FrameSizeX(%d) %d", _frame, _moveSet[_moveSetType]->getFrameWidth(_frame));
//debug("FrameSizeY(%d) %d", _frame, _moveSet[_moveSetType]->getFrameHeight(_frame));
//getState();
int16 phaseFrameIndex = _moveSet[_moveSetType]->getPhaseFrameIndex(_phase);
2014-04-28 10:15:54 +00:00
Graphics::Surface *heroFrame = _moveSet[_moveSetType]->getFrame(phaseFrameIndex);
2014-04-29 14:57:14 +00:00
return zoomSprite(heroFrame);
2013-12-05 00:02:31 +00:00
}
return NULL;
}
//TEMP
void Hero::getState() {
switch (_state) {
case STAY:
debug("STAY");
break;
case TURN:
debug("TURN");
break;
case MOVE:
debug("MOVE");
break;
case BORE:
debug("BORE");
break;
case SPEC:
debug("SPEC");
break;
case TALK:
debug("TALK");
break;
case MVAN:
debug("MVAN");
break;
case TRAN:
debug("TRAN");
break;
case RUN:
debug("RUN");
break;
case DMOVE:
debug("DMOVE");
break;
}
}
2014-04-28 10:15:54 +00:00
int Hero::getScaledValue(int size) {
int newSize = 0;
int16 initScaleValue = _scaleValue;
2014-04-29 14:57:14 +00:00
if (_scaleValue != 10000) {
2014-04-28 10:15:54 +00:00
for(int i = 0; i < size; i++) {
initScaleValue -= 100;
if(initScaleValue >= 0) {
newSize++;
} else {
initScaleValue += _scaleValue;
}
}
return newSize;
} else {
return size;
}
}
void Hero::checkNak() {
}
2014-04-29 14:57:14 +00:00
Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
2014-04-28 10:15:54 +00:00
int16 tempMiddleY;
int16 baseX = _moveSet[_moveSetType]->getBaseX();
int16 baseY = _moveSet[_moveSetType]->getBaseY();
2014-04-28 18:59:42 +00:00
// any chance?
2014-04-29 14:57:14 +00:00
if (baseX == 320) {
2014-04-28 10:15:54 +00:00
tempMiddleY = _middleY - (baseY - 240);
2014-04-28 18:59:42 +00:00
} else {
tempMiddleY = _middleY;
2014-04-28 10:15:54 +00:00
}
int16 frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase);
int16 frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase);
int scaledXSize = getScaledValue(frameXSize);
int scaledYSize = getScaledValue(frameYSize);
2014-04-29 14:57:14 +00:00
Graphics::Surface *zoomedFrame = new Graphics::Surface();
zoomedFrame->create(scaledXSize, scaledYSize, Graphics::PixelFormat::createFormatCLUT8());
2014-04-29 14:57:14 +00:00
if (_zoomFactor != 0) {
2014-04-28 18:59:42 +00:00
int sprZoomX;
int sprZoomY = _scaleValue;
uint xSource = 0;
uint ySource = 0;
uint xDest = 0;
uint yDest = 0;
2014-04-28 10:15:54 +00:00
for (int i = 0; i < scaledYSize; i++) {
2014-04-28 18:59:42 +00:00
// linear_loop:
while(1) {
sprZoomY -= 100;
2014-04-29 14:57:14 +00:00
if (sprZoomY >= 0 || _scaleValue == 10000) {
2014-04-28 18:59:42 +00:00
// all_r_y
sprZoomX = _scaleValue;
break; // to loop_lin
} else {
sprZoomY += _scaleValue;
xSource = 0;
ySource++;
2014-04-28 18:59:42 +00:00
}
}
// loop_lin:
for (int j = 0; j < scaledXSize; j++) {
2014-04-28 18:59:42 +00:00
sprZoomX -= 100;
if (sprZoomX >= 0) {
// its_all_r
memcpy(zoomedFrame->getBasePtr(xDest, yDest), heroFrame->getBasePtr(xSource, ySource), 1);
xDest++;
2014-04-28 18:59:42 +00:00
} else {
sprZoomX += _scaleValue;
j--;
2014-04-28 18:59:42 +00:00
}
xSource++;
2014-04-28 18:59:42 +00:00
}
xDest = 0;
yDest++;
xSource = 0;
ySource++;
2014-04-28 18:59:42 +00:00
}
return zoomedFrame;
2014-04-29 14:57:14 +00:00
}
return heroFrame;
}
void Hero::countDrawPosition() {
int16 tempMiddleY;
int16 baseX = _moveSet[_moveSetType]->getBaseX();
int16 baseY = _moveSet[_moveSetType]->getBaseY();
// any chance?
if (baseX == 320) {
tempMiddleY = _middleY - (baseY - 240);
} else {
tempMiddleY = _middleY;
}
int16 frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase);
int16 frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase);
int scaledX = getScaledValue(frameXSize);
int scaledY = getScaledValue(frameYSize);
//TODO
//int tempHeroHeight = scaledY; // not used? global?
//int width = scaledX / 2;
//tempMiddleX = _middleX - width; //eax
//int z = _middleY; //ebp
//int y = _middleY - scaledY; //ecx
//checkNak();
if (_zoomFactor != 0) {
//notfullSize
2014-04-28 18:59:42 +00:00
debug("scaledX: %d", scaledX);
debug("scaledY: %d", scaledY);
_drawX = _middleX - scaledX / 2;
2014-04-29 14:57:14 +00:00
_drawY = tempMiddleY + 1 - scaledY;
2014-04-28 10:15:54 +00:00
} else {
//fullSize
2014-04-28 18:59:42 +00:00
_drawX = _middleX - frameXSize / 2;
_drawY = tempMiddleY + 1 - frameYSize;
2014-04-28 10:15:54 +00:00
}
}
2014-04-29 14:57:14 +00:00
void Hero::plotPoint(int x, int y) {
WRITE_UINT16(&_shadowLine[_shadowLineLen * 4], x);
WRITE_UINT16(&_shadowLine[_shadowLineLen * 4 + 2], y);
}
static void plot(int x, int y, int color, void *data) {
Hero *shadowLine = (Hero *)data;
shadowLine->plotPoint(x, y);
shadowLine->_shadowLineLen++;
}
2014-05-11 11:57:52 +00:00
void Hero::showHeroShadow() {
int16 phaseFrameIndex = _moveSet[_moveSetType]->getPhaseFrameIndex(_phase);
Graphics::Surface *heroFrame = _moveSet[_moveSetType]->getFrame(phaseFrameIndex);
int16 frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase);
int16 frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase);
Graphics::Surface *makeShadow = new Graphics::Surface();
makeShadow->create(frameXSize, frameYSize, Graphics::PixelFormat::createFormatCLUT8());
for (int y = 0; y < frameYSize; y++) {
byte *src = (byte *)heroFrame->getBasePtr(0, y);
2014-05-11 11:57:52 +00:00
byte *dst = (byte *)makeShadow->getBasePtr(0, y);
for (int x = 0; x < frameXSize; x++, dst++, src++) {
2014-05-11 11:57:52 +00:00
if (*src != 0xFF) {
*dst = kShadowColor;
} else {
*dst = *src;
}
}
}
int scaledX = getScaledValue(frameXSize);
//int scaledY = getScaledValue(frameYSize);
int destX = _middleX - scaledX / 2;
int destY = _middleY - _shadMinus;
2014-05-04 16:02:53 +00:00
if (destY > 1 && destY < kMaxPicHeight) {
2014-05-11 11:57:52 +00:00
int shadDirection;
2014-05-04 16:02:53 +00:00
if (_lightY > destY) {
2014-05-11 11:57:52 +00:00
shadDirection = 1;
2014-05-04 16:02:53 +00:00
} else {
2014-05-11 11:57:52 +00:00
shadDirection = 0;
2014-05-04 16:02:53 +00:00
}
2014-05-11 11:57:52 +00:00
int shadWallDown = 0;
_shadowLineLen = 0;
Graphics::drawLine(_lightX, _lightY, destX, destY, 0, &plot, this);
2014-05-04 16:02:53 +00:00
2014-05-11 11:57:52 +00:00
byte *sprShadow = (byte *)_graph->_shadowTable70;
int sprWidth = frameXSize;
int sprHeight = frameYSize;
int sprDestX = destX - _vm->_picWindowX;
int sprDestY = destY - _vm->_picWindowY;
2014-05-11 11:57:52 +00:00
_shadowDrawX = sprDestX; // to fix
_shadowDrawY = sprDestY;
int shadPosX = sprDestX;
int shadMinX = sprDestX;
int shadMaxX = sprDestX;
int shadPosY = sprDestY;
int shadMinY = sprDestY;
int shadMaxY = sprDestY;
int shadBitAddr = destY * kMaxPicWidth / 8 + destX / 8;
2014-05-09 12:01:08 +00:00
int shadBitMask = 128 >> (destX % 8);
int shadZoomY2 = _shadScaleValue;
int shadZoomY = _scaleValue;
int diffX = 0;
int diffY = 0;
int blackHeroX = 0;
int blackHeroY = frameYSize - 1;
byte *shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY); // esi, first pixel from last row of black hero
byte *background = (byte *)_graph->_frontScreen->getBasePtr(sprDestX, sprDestY); // eax, pixel of background where shadow sprite starts
// banked2
2014-05-11 11:57:52 +00:00
byte *shadowLineStart = _shadowLine + 8;
// linear_loop
2014-05-11 11:57:52 +00:00
for(int i = 0; i < sprHeight; i++) {
int shadSkipX = 0;
int ct_loop = 0;
2014-05-09 12:01:08 +00:00
int ebxOnStack;
//retry_line:
2014-05-11 11:57:52 +00:00
for (ebxOnStack = sprHeight - i; ebxOnStack > 0; ebxOnStack--) {
shadZoomY -= 100;
2014-05-09 12:01:08 +00:00
if (shadZoomY < 0 && _scaleValue != 10000) {
shadZoomY += _scaleValue;
blackHeroY--;
if (blackHeroY < 0) {
break;
}
shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY);
} else {
break; //to line_y_ok
}
2014-05-09 12:01:08 +00:00
}
if(ebxOnStack == 0) {
break;
}
if (blackHeroY < 0) {
break;
}
//line_y_ok
if (shadPosY >= 0 && shadPosY < 480 && shadPosX < 640) {
if (shadPosX < 0) { //when it happens?
shadSkipX = -1 * shadPosX;
background += shadSkipX;
if (sprWidth > shadSkipX) {
shadowStart += shadSkipX;
shadBitAddr += shadSkipX / 8;
int ebp16844 = shadSkipX % 8;
if (ebp16844 != 0) {
//loop_rotate:
for (int k = 0; k < ebp16844; k++) {
//ror(shadBitMask, 1)
if (shadBitMask == 1) {
shadBitMask = 128;
shadBitAddr++;
} else {
shadBitMask /= 2;
2014-05-09 12:01:08 +00:00
}
}
2014-05-11 11:57:52 +00:00
}
} else {
//skip_line //?
// no draw_line1
//no ct_loop?
2014-05-11 11:57:52 +00:00
}
} else {
//x1_ok
if (shadPosX + sprWidth > 640) {
ct_loop = 640 - shadPosX; // test it
} else {
//draw_line
ct_loop = sprWidth;
2014-05-11 11:57:52 +00:00
}
}
//draw_line1
if (shadPosX < shadMinX) {
shadMinX = shadPosX;
}
//bigger_x
if (shadPosX + sprWidth > shadMaxX) {
shadMaxX = shadPosX + sprWidth;
}
//smaller_x
if (shadPosY < shadMinY) {
shadMinY = shadPosY;
}
//bigger_y
if (shadPosY > shadMaxY) {
shadMaxY = shadPosY;
}
//smaller_y
//retry_line2
int ebxOnStack2;
for(ebxOnStack2 = ebxOnStack; ebxOnStack2 > 0; ebxOnStack2--) {
shadZoomY2 -= 100;
if (shadZoomY2 < 0 && _shadScaleValue != 10000) {
shadZoomY2 += _shadScaleValue;
blackHeroY--;
if (blackHeroY < 0) {
break;
2014-05-11 11:57:52 +00:00
}
shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY);
} else {
break; //to line_y_ok_2
2014-05-11 11:57:52 +00:00
}
}
if (blackHeroY < 0) {
break;
}
if (ebxOnStack2 == 0) {
break;
}
//line_y_ok_2:
// push esi
// push ecx
// int lineDestAddr = eax;
// edi = eax
// eax = shadBitMask
// push eax // push shadBitMask
// lineBitAddr = shadBitMask
// eax = shadBitAddr
// push eax
// LineBitAddr = eax
//copy_trans
//push eax, ebx, edx, ebp
int shadWDFlag = 0;
int shadZoomX = _scaleValue;
int backgroundDiff = 0;
//ct_loop:
for (int j = 0; j < ct_loop; j++) {
shadZoomX -= 100;
if (shadZoomX < 0 && _scaleValue != 10000) {
blackHeroX++;
shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY);
shadZoomX += _scaleValue;
} else {
//point_ok:
if (*shadowStart == kShadowColor) {
if (shadBitMask != _shadowBitmap->getZoom(shadBitAddr)) { //tofix
if (shadWallDown == 0) {
if (shadBitMask != _shadowBitmap->getZoom(shadBitAddr + kShadowBitmapSize)) { //tofix
shadWDFlag = 1;
2014-05-11 11:57:52 +00:00
}
2014-05-09 12:01:08 +00:00
}
}
//shadow
//*background = *(sprShadow + *background); //wrong color
*background = 0;
2014-05-11 11:57:52 +00:00
}
//ct_next
//ror(shadBitMask, 1)
2014-05-11 11:57:52 +00:00
if (shadBitMask == 1) {
shadBitMask = 128;
shadBitAddr++;
} else {
shadBitMask /= 2;
}
//okok
blackHeroX++;
shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY);
backgroundDiff++;
background = (byte *)_graph->_frontScreen->getBasePtr(sprDestX + diffX + backgroundDiff, sprDestY + diffY);
2014-05-11 11:57:52 +00:00
}
}
//byebyebye
if (shadWallDown == 0 && shadWDFlag != 0) {
//shadWall etc
}
//byebye
// pop ...
if (shadDirection != 0 && shadWallDown != 0) {
// push...
// krap2
// WALL_copy_trans
2014-05-09 12:01:08 +00:00
}
}
2014-05-09 12:01:08 +00:00
//skip_line
//add esi, sprWidth - don't need it?
//next_line
if (*(shadowLineStart + 2) < *(shadowLineStart - 2)) {
//minus_y
shadBitAddr -= kMaxPicWidth / 8;
shadPosY--;
diffY--;
background = (byte *)_graph->_frontScreen->getBasePtr(sprDestX + diffX, sprDestY + diffY);
} else if (*(shadowLineStart + 2) > *(shadowLineStart - 2)) {
shadBitAddr += kMaxPicWidth / 8;
shadPosY++;
diffY++;
background = (byte *)_graph->_frontScreen->getBasePtr(sprDestX + diffX, sprDestY + diffY);
}
//no_change_y
if (*shadowLineStart < *(shadowLineStart - 4)) {
//minus_x
shadPosX--;
//rol
if (shadBitMask == 128) {
shadBitMask = 1;
shadBitAddr--;
} else {
shadBitMask *= 2;
}
diffX--;
} else if (*shadowLineStart > *(shadowLineStart - 4)) {
shadPosX++;
//ror
if (shadBitMask == 1) {
shadBitMask = 128;
shadBitAddr++;
} else {
shadBitMask /= 2;
}
diffX++;
}
//no_change_x
shadowLineStart += 4;
blackHeroY--;
if (blackHeroY < 0) {
break;
}
blackHeroX = 0;
shadowStart = (byte *)makeShadow->getBasePtr(blackHeroX, blackHeroY);
2014-05-11 11:57:52 +00:00
}
//koniec_bajki
2014-05-04 16:02:53 +00:00
}
delete makeShadow;
}
void Hero::showHeroAnimFrame() {
if (_phase < _moveSet[_moveSetType]->getFrameCount() - 1) {
_phase++;
} else {
_phase = 0;
}
countDrawPosition();
//temp:
//showHeroShadow();
//debug("_drawX: %d", _drawX);
//debug("_drawY: %d", _drawY);
//debug("_middleX: %d", _middleX);
//debug("_middleY: %d", _middleY);
}
void Hero::setScale(int8 zoomBitmapValue) {
if (zoomBitmapValue == 0) {
2014-04-28 18:59:42 +00:00
_zoomFactor = 0;
_scaleValue = 10000;
} else {
_zoomFactor = zoomBitmapValue;
2014-04-28 18:59:42 +00:00
_scaleValue = 10000 / _zoomFactor;
}
2014-04-28 18:59:42 +00:00
debug("_zoomFactor: %d", _zoomFactor);
debug("_scaleValue: %d", _scaleValue);
}
void Hero::selectZoom() {
int8 zoomBitmapValue = _zoomBitmap->getZoom(_middleY / 4 * kZoomBitmapWidth + _middleX / 4);
debug("offset: %d", _middleY / 4 * kZoomBitmapWidth + _middleX / 4);
debug("zoomBitmapValue: %d", _zoomFactor);
setScale(zoomBitmapValue);
}
void Hero::setShadowScale(int32 shadowScale) {
shadowScale = 100 - shadowScale;
if (shadowScale == 0) {
_shadZoomFactor = 0;
_shadScaleValue = 10000;
} else {
_shadZoomFactor = shadowScale;
_shadScaleValue = 10000 / _shadZoomFactor;
}
debug("_shadZoomFactor: %d", _shadZoomFactor);
debug("_shadScaleValue: %d", _shadScaleValue);
}
void Hero::specialAnim() {
}
void Hero::rotateHero() {
switch (_lastDirection) {
case LEFT:
switch (_destDirection) {
case RIGHT:
_moveSetType = Move_MLR;
break;
case UP:
_moveSetType = Move_MLU;
break;
case DOWN:
_moveSetType = Move_MLD;
break;
}
break;
case RIGHT:
switch (_destDirection) {
case LEFT:
_moveSetType = Move_MRL;
break;
case UP:
_moveSetType = Move_MRU;
break;
case DOWN:
_moveSetType = Move_MRD;
break;
}
break;
case UP:
switch (_destDirection) {
case LEFT:
_moveSetType = Move_MUL;
break;
case RIGHT:
_moveSetType = Move_MUR;
break;
case DOWN:
_moveSetType = Move_MUD;
break;
}
break;
case DOWN:
switch (_destDirection) {
case LEFT:
_moveSetType = Move_MDL;
break;
case RIGHT:
_moveSetType = Move_MDR;
break;
case UP:
_moveSetType = Move_MDU;
break;
}
break;
}
}
void Hero::showHero() {
if (_visible) {
// Is he talking?
if (_talkTime == 0) { //?
// Scale of hero
selectZoom();
switch (_state) {
case STAY:
//if(OptionsFlag == false) {
//if(OpcodePC == null) {
_boredomTime++;
if (_boredomTime == 200) { // 140 for second hero
_boredomTime = 0;
_state = BORE;
}
switch (_lastDirection) {
case LEFT:
_moveSetType = Move_SL;
break;
case RIGHT:
_moveSetType = Move_SR;
break;
case UP:
_moveSetType = Move_SU;
break;
case DOWN:
_moveSetType = Move_SD;
break;
}
break;
case TURN:
/*
if(_lastDirection == _destDirection) {
_state = STAY;
} else {
_frame = 0;
rotateHero();
_lastDirection = _destDirection;
}
*/
break;
case MOVE:
switch (_lastDirection) {
case LEFT:
_moveSetType = Move_ML;
break;
case RIGHT:
_moveSetType = Move_MR;
break;
case UP:
_moveSetType = Move_MU;
break;
case DOWN:
_moveSetType = Move_MD;
break;
}
break;
case BORE:
//if (_direction == UP) {
switch (_boreNum) {
case 0:
_moveSetType = Move_BORED1;
break;
case 1:
_moveSetType = Move_BORED2;
break;
}
if (_phase == _moveSet[_moveSetType]->getFrameCount() - 1) {
_boreNum = _randomSource.getRandomNumber(1); // rand one of two 'bored' animation
_lastDirection = DOWN;
_state = STAY;
}
break;
case SPEC:
//specialAnim();
break;
case TALK:
switch (_lastDirection) {
case LEFT:
_moveSetType = Move_TL;
break;
case RIGHT:
_moveSetType = Move_TR;
break;
case UP:
_moveSetType = Move_TU;
break;
case DOWN:
_moveSetType = Move_TD;
break;
}
break;
case TRAN:
break;
case RUN:
break;
case DMOVE:
break;
}
} else {
_talkTime--; // o ile?
}
showHeroAnimFrame();
} else {
// no hero visible
return;
}
}
2014-05-04 16:02:53 +00:00
void Hero::scrollHero() {
//FLAGI+SCROLLTYPE ??
//int scrollType = 0;
int position = _middleX;
/*
switch (scrollType) {
case 0:
position = _middleX;
break;
case 1:
break;
case 2:
break;
}
*/
int locationWidth = _vm->_sceneWidth;
int difference = locationWidth - kNormalWidth / 2;
int destValue = 0;
if (position > kNormalWidth / 2) {
destValue = difference - kNormalWidth / 2;
}
if (position < difference) {
destValue = position - kNormalWidth / 2;
}
if(destValue < 0) {
destValue = 0;
}
_vm->_picWindowX = destValue;
_drawX -= destValue;
}
}
/* vim: set tabstop=4 noexpandtab: */