scummvm/engines/queen/walk.h

145 lines
3.5 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.
2003-10-09 09:09:40 +00:00
*
* 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.
2003-10-09 09:09:40 +00:00
*
*/
2006-11-12 17:47:16 +00:00
#ifndef QUEEN_WALK_H
#define QUEEN_WALK_H
2003-10-09 09:09:40 +00:00
2003-12-01 20:48:41 +00:00
#include "common/util.h"
2003-10-09 09:09:40 +00:00
#include "queen/structs.h"
namespace Queen {
struct MovePersonAnim {
int16 firstFrame;
int16 lastFrame;
2004-01-08 16:41:03 +00:00
Direction facing;
2003-10-09 09:09:40 +00:00
2004-01-08 16:41:03 +00:00
void set(int16 ff, int16 lf, Direction dir) {
2003-10-09 09:09:40 +00:00
firstFrame = ff;
lastFrame = lf;
2004-01-08 16:41:03 +00:00
facing = dir;
2003-10-09 09:09:40 +00:00
}
};
struct WalkData {
int16 dx, dy;
const Area *area;
uint16 areaNum;
MovePersonAnim anim;
};
struct MovePersonData {
const char *name;
int16 walkLeft1, walkLeft2;
int16 walkRight1, walkRight2;
int16 walkBack1, walkBack2;
int16 walkFront1, walkFront2;
uint16 frontStandingFrame;
uint16 backStandingFrame;
uint16 animSpeed;
uint16 moveSpeed;
};
2003-12-11 22:16:35 +00:00
class QueenEngine;
2003-10-09 09:09:40 +00:00
class Walk {
public:
2003-12-11 22:16:35 +00:00
Walk(QueenEngine *vm);
2003-10-09 09:09:40 +00:00
int16 moveJoe(int direction, int16 endx, int16 endy, bool inCutaway);
int16 movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage, int direction);
void stopJoe();
void stopPerson(uint16 bobNum);
2003-12-12 20:26:20 +00:00
enum {
MAX_WALK_DATA = 16
};
2003-10-09 09:09:40 +00:00
private:
2003-10-09 09:09:40 +00:00
void animateJoePrepare();
void animateJoe();
2003-10-09 09:09:40 +00:00
void animatePersonPrepare(const MovePersonData *mpd, int direction);
void animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, uint16 bankNum, int direction);
2003-10-09 09:09:40 +00:00
/// compute transition coordinate
static int16 calcC(int16 c1, int16 c2, int16 c3, int16 c4, int16 lastc);
/// find area for position
int16 findAreaPosition(int16 *x, int16 *y, bool recalibrate);
2003-10-09 09:09:40 +00:00
/// find an area not already struck
2003-10-09 09:09:40 +00:00
uint16 findFreeArea(uint16 area) const;
/// return true if the area is already on the walking path
2003-10-09 09:09:40 +00:00
bool isAreaStruck(uint16 area) const;
/// calculates the path list from oldArea to newArea
2003-10-09 09:09:40 +00:00
bool calcPath(uint16 oldArea, uint16 newArea);
/// resets path computed in calcPath()
2003-10-09 09:09:40 +00:00
void initWalkData();
/// add an area to the path
void incWalkData(int16 px, int16 py, int16 x, int16 y, uint16 area);
/// compute path (and populates _walkData) from current position to the new one
bool calc(uint16 oldPos, uint16 newPos, int16 oldx, int16 oldy, int16 x, int16 y);
2003-10-09 09:09:40 +00:00
/// areas for current room
const Area *_roomArea;
/// number of areas for current room
uint16 _roomAreaCount;
/// walking steps
WalkData _walkData[MAX_WALK_DATA];
/// number of walking steps
2003-10-09 09:09:40 +00:00
uint16 _walkDataCount;
uint16 _areaStrike[MAX_WALK_DATA];
2003-10-09 09:09:40 +00:00
uint16 _areaStrikeCount;
uint16 _areaList[MAX_WALK_DATA];
2003-10-09 09:09:40 +00:00
uint16 _areaListCount;
/// set if stopJoe() is called
bool _joeInterrupted;
/// set if handleSpecialArea() is called
bool _joeMoveBlock;
2003-12-11 22:16:35 +00:00
QueenEngine *_vm;
/// persons walking animation data
static const MovePersonData _moveData[];
2003-10-09 09:09:40 +00:00
};
} // End of namespace Queen
#endif