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 ACCESS_PLAYER_H
24 #define ACCESS_PLAYER_H
25 
26 #include "common/scummsys.h"
27 #include "common/rect.h"
28 #include "common/serializer.h"
29 #include "access/asurface.h"
30 #include "access/data.h"
31 
32 namespace Access {
33 
34 enum Direction {
35 	NONE = 0,
36 	UP = 1,
37 	DOWN = 2,
38 	LEFT = 3,
39 	RIGHT = 4,
40 	UPRIGHT = 5,
41 	DOWNRIGHT = 6,
42 	UPLEFT = 7,
43 	DOWNLEFT = 8
44 };
45 
46 class AccessEngine;
47 
48 class Player : public ImageEntry, public Manager {
49 protected:
50 	int _leftDelta, _rightDelta;
51 	int _upDelta, _downDelta;
52 	int _scrollConst;
53 	int _sideWalkMin, _sideWalkMax;
54 	int _upWalkMin, _upWalkMax;
55 	int _downWalkMin, _downWalkMax;
56 	int _diagUpWalkMin, _diagUpWalkMax;
57 	int _diagDownWalkMin, _diagDownWalkMax;
58 	SpriteResource *_playerSprites1;
59 	int _scrollEnd;
60 	int _inactiveYOff;
61 
62 	void plotCom(int v1);
63 	void plotCom0();
64 	void plotCom1();
65 	void plotCom2();
66 	void plotCom3();
67 
68 	void walkUp();
69 	void walkDown();
70 	void walkLeft();
71 	void walkRight();
72 	void walkUpLeft();
73 	void walkDownLeft();
74 	void walkUpRight();
75 	void walkDownRight();
76 	void checkScrollUp();
77 public:
78 	Direction _playerDirection;
79 	SpriteResource *_playerSprites;
80 	// Fields in original Player structure
81 	byte *_manPal1;
82 	int *_walkOffRight;
83 	int *_walkOffLeft;
84 	int *_walkOffUp;
85 	int *_walkOffDown;
86 	Common::Point *_walkOffUR;
87 	Common::Point *_walkOffDR;
88 	Common::Point *_walkOffUL;
89 	Common::Point *_walkOffDL;
90 	byte _rawTempL;
91 	int _rawXTemp;
92 	byte _rawYTempL;
93 	int _rawYTemp;
94 	Common::Point _playerOffset;
95 	int _playerXLow;
96 	int _playerX;
97 	int _playerYLow;
98 	int _playerY;
99 	int _frame;
100 	int _xFlag, _yFlag;
101 	Direction _move;
102 
103 	// Additional public globals we've added to new Player class
104 	bool _playerOff;
105 	bool _playerMove;
106 	Common::Point _moveTo;
107 	bool _collideFlag;
108 	bool _scrollFlag;
109 	int _scrollThreshold;
110 	int _scrollAmount;
111 
112 	// Additional globals that need to be saved
113 	int _roomNumber;
114 	Common::Point _rawPlayerLow;
115 	Common::Point _rawPlayer;
116 public:
117 	Player(AccessEngine *vm);
118 	virtual ~Player();
119 	static Player *init(AccessEngine *vm);
120 
121 	virtual void load();
122 
123 	void loadTexPalette();
124 
125 	void loadSprites(const Common::String &name);
126 
127 	void freeSprites();
128 
129 	void removeSprite1();
130 
131 	void calcManScale();
132 
133 	void walk();
134 
135 	void calcPlayer();
136 
137 	bool scrollUp(int forcedAmount = -1);
138 	bool scrollDown(int forcedAmount = -1);
139 	bool scrollLeft(int forcedAmount = -1);
140 	bool scrollRight(int forcedAmount = -1);
141 	void checkScroll();
142 
143 	void checkMove();
144 
145 	/**
146 	* Synchronize savegame data
147 	*/
148 	void synchronize(Common::Serializer &s);
149 };
150 
151 } // End of namespace Access
152 
153 #endif /* ACCESS_PLAYER_H */
154