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 DARKSEED_PLAYER_H
23 #define DARKSEED_PLAYER_H
24 
25 #include "common/rect.h"
26 #include "common/path.h"
27 #include "darkseed/nsp.h"
28 
29 namespace Darkseed {
30 
31 class Player {
32  Nsp _cPlayerSprites;
33  Nsp _gPlayerSprites;
34 
35 public:
36  Nsp _animations;
37  int _frameIdx = 0;
38  int _direction = 0;
39  Common::Point _position;
40  Common::Point _positionLong; // the original sometimes seems to use a long (4 byte) version of the location
41  Common::Point _walkTarget;
42  Common::Point _finalTarget;
43 
44  int16 _playerSpriteWalkIndex_maybe = 0;
45  int16 _playerWalkFrameDeltaOffset = 0;
46  int16 _playerNewFacingDirection_maybe = 0;
47  uint16 _playerWalkFrameIdx = 0;
48  bool _actionToPerform = false; // player is pathfinding to some destination?
49  bool _playerIsChangingDirection = false; // AKA _Rotating
50  bool _isAutoWalkingToBed = false;
51  bool _heroMoving = false; // maybe set to true while player is walking around the room.
52  bool _heroWaiting = false;
53  int _walkPathIndex = -1;
54  uint16 _numConnectorsInWalkPath = 0;
55  Common::Array<Common::Point> _connectorList;
56  int16 _sequenceRotation = -1;
57  bool _walkToSequence = false;
58  Common::Point _walkToSequencePoint;
59  bool _flipSprite = false;
60 
61  Player();
62  bool loadAnimations(const Common::Path &filename);
63  const Sprite &getSprite(int frameNo) const;
64  void updateSprite();
65  void draw();
66 
67  bool isAtPosition(int x, int y) const;
68  bool isAtWalkTarget() const;
69  void calculateWalkTarget();
70 
71  void changeDirection(int16 oldDir, int16 newDir);
72  void playerFaceWalkTarget();
73  int getWidth();
74  int getHeight();
75  void updatePlayerPositionAfterRoomChange();
76  void setPlayerTowardsBedroom();
77  void walkToNextConnector();
78 
79 private:
80  void createConnectorPathToDest();
81  Common::Point getClosestUnusedConnector(int16 x, int16 y, bool mustHaveCleanLine = false);
82  void reverseConnectorList();
83  void optimisePath();
84 };
85 
86 } // namespace Darkseed
87 
88 #endif // DARKSEED_PLAYER_H
Definition: path.h:52
Definition: nsp.h:61
Definition: rect.h:45
Definition: nsp.h:33
Definition: player.h:31
Definition: adlib_worx.h:27