ScummVM API documentation
hero.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * file distributed with this source distribution.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 /*
22  * This code is based on original Sfinx source code
23  * Copyright (c) 1994-1997 Janusz B. Wisniewski and L.K. Avalon
24  */
25 
26 #ifndef CGE2_HERO_H
27 #define CGE2_HERO_H
28 
29 #include "cge2/cge2.h"
30 #include "cge2/vga13h.h"
31 #include "cge2/snail.h"
32 
33 namespace CGE2 {
34 
35 #define kMaxTry 400
36 
37 class Hero;
38 
39 struct HeroTab {
40  Hero *_ptr;
41  Sprite *_face;
42  Sprite *_pocket[kPocketMax + 1];
43  int _downPocketId[kPocketMax + 1];
44  int _pocPtr;
45  V2D *_posTab[kSceneMax];
46  HeroTab(CGE2Engine *vm) {
47  _ptr = nullptr;
48  _face = nullptr;
49  for (int i = 0; i < kPocketMax + 1; i++) {
50  _pocket[i] = nullptr;
51  _downPocketId[i] = -1;
52  }
53  _pocPtr = 0;
54  for (int i = 0; i < kSceneMax; i++)
55  _posTab[i] = nullptr;
56  }
57  ~HeroTab() {
58  for (int i = 0; i < kSceneMax; i++)
59  delete _posTab[i];
60  }
61 };
62 
63 class Hero : public Sprite {
64  int _hig[kDimMax];
65  Sprite *_contact;
66 public:
67  BitmapPtr _dim[kDimMax];
68  V3D _trace[kWayMax];
69  enum Dir { kNoDir = -1, kSS, kWW, kNN, kEE } _dir;
70  int _curDim;
71  int _tracePtr;
72  int _reachStart, _reachCycle, _sayStart, _funStart;
73  int _funDel0, _funDel;
74  int _maxDist;
75  bool _ignoreMap;
76  Hero(CGE2Engine *vm);
77  ~Hero() override;
78  void tick() override;
79  Sprite *expand() override;
80  Sprite *contract() override;
81  Sprite *setContact();
82  int stepSize() { return _ext->_seq[7]._dx; }
83  int distance(V3D pos);
84  int distance(Sprite * spr);
85  void turn(Dir d);
86  void park();
87  int len(V2D v);
88  bool findWay();
89  static int snap(int p, int q, int grid);
90  void walkTo(V3D pos);
91  void walkTo(V2D pos) { walkTo(screenToGround(pos)); }
92  V3D screenToGround(V2D pos);
93  void walkTo(Sprite *spr);
94  void say() { step(_sayStart); }
95  void fun();
96  void resetFun() { _funDel = _funDel0; }
97  void hStep();
98  bool lower(Sprite * spr);
99  int cross(const V2D &a, const V2D &b);
100  int mapCross(const V2D &a, const V2D &b);
101  int mapCross(const V3D &a, const V3D &b);
102  Hero *other() { return _vm->_heroTab[!(_ref & 1)]->_ptr;}
103  Action action() { return (Action)(_ref % 10); }
104  void reach(int mode);
105  void setCurrent();
106  void setScene(int c) override;
107  void operator++();
108  void operator--();
109 };
110 
111 } // End of namespace CGE2
112 
113 #endif // CGE2_HERO_H
Definition: cge2.h:149
Definition: vga13h.h:152
Definition: vga13h.h:94
Definition: vga13h.h:78
Definition: bitmap.h:33
Definition: bitmap.h:57
Definition: hero.h:39
Definition: hero.h:63