The Game Engine  1
Player.h
Go to the documentation of this file.
1 #ifndef __PLAYER_H__
2 #define __PLAYER_H__
3 #include <vector>
4 #include <string>
5 #include "Input.h"
6 #include "WorldObject.h"
7 
8 
18 class Player
19 {
20 public:
21  Player(string filename);
22 
27  enum InputAction {
29  Deny,
31  Esc,
54  HotKey12,//probably going to be unusued
59  };
60 
61  Player(map<InputAction, vector<SDLKey>> keyMaps);
62 
63  Player(map<InputAction, vector<JoyStick>> joyMaps, map<InputAction, vector<JoyButton>> buttonMaps, int moveJoy = 0 );
64 
69  void Control(WorldObject* wo);
70 
75  void RemoveControl(WorldObject* wo);
76 
81  void RemoveControl(string woName);
82 
88  WorldObject* getObject(string name);
89 
96  WorldObject* getObject(unsigned int index);
97 
102  vector<WorldObject*> getObjects();
103 
111  vector<WorldObject*> getObjects(string name, int count = -1);
112 
113 
119 
125  Point2D getAveragePosition(string name);
126 
135  Point2D getAveragePosition(vector<int> indices);
136 
144  Point2D getAveragePosition(vector<string> names);
145 
152  void setPosition(double x, double y);
153 
159  void setPosition(Point2D pos);
160 
166  void move(double dx, double dy);
167 
172  void move(Point2D direction);
173 
178  void moveTowards(Point2D point);
179 
185  void setTransparency(float f);
186 
192  void changeTransparency(float df);
193 
198  void addKeyDownCallback(void (*fn)(SDLKey, SDLMod));
199 
204  void removeKeyDownCallback(void (*fn)(SDLKey, SDLMod));
205 
210  void addKeyUpCallback(void (*fn)(SDLKey, SDLMod));
211 
216  void removeKeyUpCallback(void (*fn)(SDLKey, SDLMod));
217 
222  void addMouseDownCallback(void (*fn)(Uint8, Input::MouseState));
223 
228  void removeMouseDownCallback(void (*fn)(Uint8, Input::MouseState));
229 
234  void addMouseUpCallback(void (*fn)(Uint8, Input::MouseState));
235 
240  void removeMouseUpCallback(void (*fn)(Uint8, Input::MouseState));
241 
246  void addMouseMoveCallback(void (*fn)(Input::MouseState));
247 
252  void removeMouseMoveCallback(void (*fn)(Input::MouseState));
253 
258  void addJoyButtonDownCallback(void (*fn)(Uint8, JoyButton));
259 
264  void removeJoyButtonDownCallback(void (*fn)(Uint8, JoyButton));
265 
270  void addJoyButtonUpCallback(void (*fn)(Uint8, JoyButton));
271 
276  void removeJoyButtonUpCallback(void (*fn)(Uint8, JoyButton));
277 
282  void addJoyMoveCallback(void (*fn)(Uint8, JoyStick, Point2D));
283 
288  void removeJoyMoveCallback(void (*fn)(Uint8, JoyStick, Point2D));
289 
294  static bool getAllPressed(InputAction act);
295 
301  static bool getAllTriggered(InputAction act, int ms=-1);
302 
308  static Point2D getAllMovement(InputAction act = Move);
309 
318 
324  bool pressed(InputAction act);
325 
332  bool triggered(InputAction act, int ms=-1);
333 
340  bool doubleTapped(InputAction act, int ms=-1);
341 
342 
343 protected:
345  vector<WorldObject*> mObjects;
346 
349 
351  map<InputAction, vector<SDLKey>> mKeyMaps;
352 
354  map<InputAction, vector<JoyButton>> mJoyButtonMaps;
355 
357  map<InputAction, vector<JoyStick>> mJoyStickMaps;
358 
361 };
362 #endif