ScummVM API documentation
player.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MADS_PLAYER_H
23 #define MADS_PLAYER_H
24 
25 #include "common/scummsys.h"
26 #include "common/str.h"
27 #include "common/serializer.h"
28 
29 namespace MADS {
30 
31 class MADSEngine;
32 class MADSAction;
33 
34 #define PLAYER_SPRITES_FILE_COUNT 8
35 #define MAX_ROUTE_NODES 22
36 
40 enum Facing {
41  FACING_NORTH = 8, FACING_SOUTH = 2, FACING_EAST = 6, FACING_WEST = 4,
42  FACING_NORTHEAST = 9, FACING_SOUTHEAST = 3,
43  FACING_SOUTHWEST = 1, FACING_NORTHWEST = 7,
44  FACING_NONE = 5, FACING_DUMMY = 0
45 };
46 
48  int _stack;
49  int _trigger;
50 
51  StopWalkerEntry() : _stack(0), _trigger(0) {}
52  StopWalkerEntry(int stack, int trigger) : _stack(stack), _trigger(trigger) {}
53 
54  void synchronize(Common::Serializer &s);
55 };
56 
57 class StopWalkers : public Common::FixedStack<StopWalkerEntry, 12> {
58 public:
60 
61  void synchronize(Common::Serializer &s);
62 };
63 
64 class Player {
65 private:
66  static const int _directionListIndexes[32];
67 private:
68  MADSEngine *_vm;
69  bool _highSprites;
70  bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
71  bool _mirror;
72  int _frameCount;
73  int _frameListIndex;
74  int _distAccum;
75  int _pixelAccum;
76  int _deltaDistance;
77  int _totalDistance;
78 
79  void clearStopList();
80 
84  void move();
85 
89  void setFrame();
90 
94  int getSpriteSlot();
95 
99  int getScale(int yp);
100 
104  void setBaseFrameRate();
105 
109  void startMovement();
110 
111  void changeFacing();
112 
113  void activateTrigger();
114 public:
115  MADSAction *_action;
116 
117  Facing _facing;
118  Facing _turnToFacing;
119  Facing _prepareWalkFacing;
120  int _xDirection, _yDirection;
121  Facing _targetFacing;
122  bool _spritesLoaded;
123  int _spritesStart;
124  int _spritesIdx;
125  int _numSprites;
126  bool _stepEnabled;
127  bool _spritesChanged;
128  bool _visible;
129  bool _priorVisible;
130  bool _beenVisible;
131  bool _walkAnywhere;
132  int _frameNumber;
133  bool _loadsFirst;
134  bool _loadedFirst;
135  Common::Point _playerPos;
136  Common::Point _targetPos;
137  Common::Point _posChange;
138  Common::Point _posDiff;
139  Common::Point _prepareWalkPos;
140  bool _moving;
141  int _walkOffScreen, _walkOffScreenSceneId;
142  int _special;
143  int _ticksAmount;
144  uint32 _priorTimer;
145  int _velocity;
146  int _upcomingTrigger;
147  int _trigger;
148  bool _scalingVelocity;
149  bool _forceRefresh;
150  bool _forcePrefix;
151  bool _needToWalk;
152  bool _readyToWalk;
153  bool _commandsAllowed;
154  bool _enableAtTarget;
155  int _centerOfGravity;
156  int _currentDepth;
157  int _currentScale;
158  Common::String _spritesPrefix;
159 
160  int _walkTrigger;
161  TriggerMode _walkTriggerDest;
162  ActionDetails _walkTriggerAction;
163  StopWalkers _stopWalkers;
164 public:
165  Player(MADSEngine *vm);
166 
170  bool loadSprites(const Common::String &prefix);
171 
176  void setFinalFacing();
177 
181  void cancelWalk();
182 
186  void cancelCommand();
187 
191  void selectSeries();
192 
193  /*
194  * Moves to the next frame for the currently active player sprite set
195  */
196  void updateFrame();
197 
198  void update();
199 
203  void idle();
204 
210  void startWalking(const Common::Point &pt, Facing facing);
211 
217  void walk(const Common::Point &pos, Facing facing);
218 
223  void newWalk();
224 
225  void nextFrame();
226 
230  void addWalker(int walker, int trigger);
231 
235  void releasePlayerSprites();
236 
240  void synchronize(Common::Serializer &s);
241 
242  static void preloadSequences(const Common::String &prefix, int level) {
243  // No implementation in ScummVM
244  }
245 
246  void removePlayerSprites();
247 
248  void firstWalk(Common::Point fromPos, Facing fromFacing, Common::Point destPos, Facing destFacing, bool enableFl);
249 
250  void setWalkTrigger(int val);
251 
252  void resetFacing(Facing facing);
253 
254 };
255 
256 } // End of namespace MADS
257 
258 #endif /* MADS_PLAYER_H */
Definition: player.h:57
Definition: str.h:59
Definition: action.h:103
Definition: serializer.h:79
Definition: stack.h:43
Definition: rect.h:45
Definition: action.h:75
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: mads.h:87
Facing
Definition: player.h:40
Definition: action.h:28
Definition: player.h:47
Definition: player.h:64