ScummVM API documentation
china_train.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 DGDS_MINIGAMES_CHINA_TRAIN_H
23#define DGDS_MINIGAMES_CHINA_TRAIN_H
24
25namespace Dgds {
26
27enum PlayerType {
28 kPlayerLucky,
29 kPlayerTong,
30};
31
32enum PlayerAction {
33 // The list of actions is not directly referenced in the game, but is in
34 // the exe just after the "Heart of China Train Game" copyright
35 kActionStandRight = 0,
36 kActionWalkRight = 1,
37 kActionWalkLeft = 2,
38 kActionJumpRight = 3,
39 kActionJumpLeft = 4,
40 kActionDuckRight = 5,
41 kActionFallRight = 6,
42 kActionFallLeft = 7,
43 kActionStagger = 8,
44 kActionDeathScene = 9,
45 kActionClub = 10,
46 kActionClubHit = 11,
47 kActionSwing = 12,
48 kActionSwingHit = 13,
49 kActionStab = 14,
50 kActionStabHit = 15,
51 kActionBlock = 16,
52 kActionHeroicJump = 17,
53 kActionBlockUp = 18,
54 kActionFree6 = 19,
55 kActionStandLeft = 20,
56 kActionDuckLeft = 21,
57 kActionFree7 = 22,
58 kActionFree8 = 23,
59 kActionERROR = 24,
60};
61
62enum PlayerIntent {
63 kIntentDuck = 0,
64 kIntentRest = 1,
65 kIntentPursue = 2,
66 kIntentAttack = 3,
67 kIntentRetreat = 4,
68 kIntentQ = 5,
69 kIntentInvalid = 255,
70};
71
72class TrainPlayers;
73
74struct PlayerData {
75 int16 _frame; // field 0
76 ImageFlipMode _flipMode; // field 1
77 int16 _xstep; // field 2
78 int16 _ystep; // field 3
79 int16 _xoff; // field 4
80 int16 _yoff; // field 5
81 int16 _val6; // field 6
82};
83
84struct TunnelData {
85 TunnelData() : _start(0), _end(0) {}
86 int32 _start;
87 int32 _end;
88};
89
91public:
92 friend class TrainPlayers;
93 TrainPlayer(PlayerType type);
94
95 bool isBlocking() const { return _action == kActionBlock || _action == kActionBlockUp; }
96 bool isDucking() const { return _action == kActionDuckRight || _action == kActionDuckLeft; }
97 bool isFalling() const { return _action == kActionFallRight || _action == kActionFallLeft; }
98 bool isJumping() const { return _action == kActionJumpRight || _action == kActionJumpLeft; }
99 bool isStaggering() const { return _action == kActionStagger; }
100 bool isStanding() const { return _action == kActionStandRight || _action == kActionStandLeft; }
101 bool isWalking() const { return _action == kActionWalkLeft || _action == kActionWalkRight; }
102
103 bool isTong() const { return _type == kPlayerTong; }
104 bool isLucky() const { return _type == kPlayerLucky; }
105
106 void checkLives();
107 void doAttack(TrainPlayer &other);
108 void doBlock();
109 void doClub(int16 damage);
110 void doPursue(const TrainPlayer &other);
111 void doRun();
112 void doJump();
113 void setAction(PlayerAction state, bool flag);
114 bool inRange(const TrainPlayer &other);
115 void hit(int16 damage);
116 void startStagger(const TrainPlayer &other);
117 void readStuff(const Common::String &path);
118 void computerDucks();
119 void checkDuck(const TunnelData &currentTunnel);
120 void doProcess();
121
122 PlayerType _type;
123 int16 _xpos;
124 int16 _ypos;
125 PlayerAction _action;
126 int16 _fatigue;
127 int16 _hitpoints;
128 PlayerIntent _intent;
129 int16 _ferocity;
130 int16 _val7;
132 Common::Array<PlayerData> *_currentActionData;
133 PlayerData *_data;
134
135private:
136 TrainPlayer &chooseEnemy();
137 PlayerData *endOfCurrentAction();
138 PlayerData *startOfCurrentAction();
139
140 static int16 _blockSoundFlag;
141};
142
144public:
145 TrainPlayers();
146
147 void initPlayers();
148 void checkLives();
149 void readAnims();
150 void freeAnims();
151 void doScroll(int16 jumpOffset);
152
153 TrainPlayer _lucky;
154 TrainPlayer _tong;
155};
156
157
160public:
161 ChinaTrain();
162
163 void init(); // aka arcadeInit
164 int16 tick(); // aka arcadeLoop
165 void end(); // aka aracdeReset
166
167 //int16 currentCar() const { return _currentCar; }
168 void checkTongFall(int16 xpos, int16 car);
169 TrainPlayers &getPlayers() { return _players; }
170 const TunnelData &getCurrentTunnel() const { return _currentTunnel; }
171 void leaveArcade();
172 bool checkGap(int16 xpos, int16 offset);
173
174 void onKeyDown(Common::KeyState kbd);
175 void onKeyUp(Common::KeyState kbd);
176 void setMenuResult(bool yes);
177
178 int16 _jumpOffset;
179
180private:
181 void arcadeFadeout();
182 void getUserInput();
183 void getNpcInput();
184 void processInput();
185 void handleVariables();
186 void drawFrame();
187 int16 trainArcade();
188 void trainRestart();
189 void lost();
190 void makeNewTunnel();
191 //void setupArcade(); // just sets fill=1 and _clipWin.
192 void initScoreWindow();
193 void drawBorder();
194 void shadeLabel(int16 x, int16 y, int16 w, int16 h, const char *label);
195 void shadeBox(Graphics::ManagedSurface &buf, byte backCol, byte foreCol, byte fill, int16 x, int16 y, int16 w, int16 h);
196
197 void fixBorder();
198 void drawCommandButtons();
199 void drawBmps();
200 void drawTunnel();
201 void drawMountains(int16 num);
202 void drawBlock(int16 x1, int16 x2, int16 param_3, int16 y1, int16 y2, int16 param_6, int16 param_7, int16 param_8);
203 void drawButtons(int16 *buttons);
204 void shadePressButton(int16 x, int16 y);
205 void shadeButton(int16 x, int16 y);
206 void drawScoreWindow();
207 void drawScore();
208 void drawSnow();
209 void drawTrain();
210 void drawActors();
211 void drawCar(int16 xoff, int16 frame, int16 yoff);
212 void fixUpTunnel();
213 bool calcBounce(int16 car);
214 void checkRegions(TrainPlayer &player);
215 void processOrders(TrainPlayer &player, TrainPlayer &enemy);
216 int16 readButtons();
217 void cabooseLost();
218
219 int16 _arcadeCount;
220 int16 _arcadeFlag;
221 bool _arcadeInitFlag;
222 int16 _arcadeDrawFlag;
223
224 int16 _failCounter;
225 int16 _lastMaskedArcadeFlag;
226 int16 _int3036;
227 int16 _tongAttackCounter;
228 int16 _tongInjuredCounter;
229 int16 _tongRestTarget;
230 int16 _lastTongHP;
231 int16 _lastTongFatigue;
232 TrainPlayers _players;
233 int16 _currentCar;
234 int32 _trackPos;
235 int32 _frameCnt;
236 int16 _xOffset;
237 int16 _tunnelNum;
238 TunnelData _currentTunnel;
239 int16 _cabooseTrail;
240 int16 _lastBtn;
241 const Common::Rect _clipWin;
242 //Common::SharedPtr<Image> _simChars;
243 Common::SharedPtr<Image> _rectShape;
244 Common::SharedPtr<Image> _luckyMaps;
246 int16 _pressedCommandButton;
247 bool _leftButtonDown;
248 bool _rightButtonDown;
249 int16 _lastKeycode;
250 bool _playedTunnelSFX;
251};
252
253} // end namespace Dgds
254
255#endif // DGDS_MINIGAMES_CHINA_TRAIN_H
Definition: array.h:52
Definition: ptr.h:159
Definition: str.h:59
Definition: china_train.h:159
Definition: china_train.h:90
Definition: china_train.h:143
Definition: managed_surface.h:51
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: keyboard.h:294
Definition: rect.h:536
Definition: china_train.h:74
Definition: china_train.h:84