1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef QUEEN_WALK_H 24 #define QUEEN_WALK_H 25 26 #include "common/util.h" 27 #include "queen/structs.h" 28 29 namespace Queen { 30 31 struct MovePersonAnim { 32 int16 firstFrame; 33 int16 lastFrame; 34 Direction facing; 35 setMovePersonAnim36 void set(int16 ff, int16 lf, Direction dir) { 37 firstFrame = ff; 38 lastFrame = lf; 39 facing = dir; 40 } 41 }; 42 43 struct WalkData { 44 int16 dx, dy; 45 const Area *area; 46 uint16 areaNum; 47 MovePersonAnim anim; 48 }; 49 50 struct MovePersonData { 51 const char *name; 52 int16 walkLeft1, walkLeft2; 53 int16 walkRight1, walkRight2; 54 int16 walkBack1, walkBack2; 55 int16 walkFront1, walkFront2; 56 uint16 frontStandingFrame; 57 uint16 backStandingFrame; 58 uint16 animSpeed; 59 uint16 moveSpeed; 60 }; 61 62 class QueenEngine; 63 64 class Walk { 65 public: 66 67 Walk(QueenEngine *vm); 68 69 int16 moveJoe(int direction, int16 endx, int16 endy, bool inCutaway); 70 int16 movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage, int direction); 71 72 void stopJoe(); 73 void stopPerson(uint16 bobNum); 74 75 enum { 76 MAX_WALK_DATA = 16 77 }; 78 79 private: 80 81 void animateJoePrepare(); 82 void animateJoe(); 83 84 void animatePersonPrepare(const MovePersonData *mpd, int direction); 85 void animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, uint16 bankNum, int direction); 86 87 /// compute transition coordinate 88 static int16 calcC(int16 c1, int16 c2, int16 c3, int16 c4, int16 lastc); 89 90 /// find area for position 91 int16 findAreaPosition(int16 *x, int16 *y, bool recalibrate); 92 93 /// find an area not already struck 94 uint16 findFreeArea(uint16 area) const; 95 96 /// return true if the area is already on the walking path 97 bool isAreaStruck(uint16 area) const; 98 99 /// calculates the path list from oldArea to newArea 100 bool calcPath(uint16 oldArea, uint16 newArea); 101 102 /// resets path computed in calcPath() 103 void initWalkData(); 104 105 /// add an area to the path 106 void incWalkData(int16 px, int16 py, int16 x, int16 y, uint16 area); 107 108 /// compute path (and populates _walkData) from current position to the new one 109 bool calc(uint16 oldPos, uint16 newPos, int16 oldx, int16 oldy, int16 x, int16 y); 110 111 112 /// areas for current room 113 const Area *_roomArea; 114 115 /// number of areas for current room 116 uint16 _roomAreaCount; 117 118 /// walking steps 119 WalkData _walkData[MAX_WALK_DATA]; 120 121 /// number of walking steps 122 uint16 _walkDataCount; 123 124 uint16 _areaStrike[MAX_WALK_DATA]; 125 uint16 _areaStrikeCount; 126 127 uint16 _areaList[MAX_WALK_DATA]; 128 uint16 _areaListCount; 129 130 /// set if stopJoe() is called 131 bool _joeInterrupted; 132 133 /// set if handleSpecialArea() is called 134 bool _joeMoveBlock; 135 136 QueenEngine *_vm; 137 138 /// persons walking animation data 139 static const MovePersonData _moveData[]; 140 }; 141 142 } // End of namespace Queen 143 144 #endif 145