| 1 | /*! | 
|---|
| 2 |  * @file player.h | 
|---|
| 3 |  * Implements a basic controllable WorldEntity | 
|---|
| 4 |  */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _PLAYER_H | 
|---|
| 7 | #define _PLAYER_H | 
|---|
| 8 |  | 
|---|
| 9 | #include "world_entity.h" | 
|---|
| 10 | #include "physics_interface.h" | 
|---|
| 11 | #include "event_listener.h" | 
|---|
| 12 |  | 
|---|
| 13 | template<class T> class tList; | 
|---|
| 14 | class Weapon; | 
|---|
| 15 | class WeaponManager; | 
|---|
| 16 | class Vector; | 
|---|
| 17 | class Event; | 
|---|
| 18 |  | 
|---|
| 19 | //! Basic controllable WorldEntity | 
|---|
| 20 | /** | 
|---|
| 21 |   *  this is the debug player - actualy we would have to make a new | 
|---|
| 22 |      class derivated from Player for each player. for now, we just use | 
|---|
| 23 |      the player.cc for debug also | 
|---|
| 24 | */ | 
|---|
| 25 | class Player : public WorldEntity, public PhysicsInterface, public EventListener | 
|---|
| 26 | { | 
|---|
| 27 |   friend class World; | 
|---|
| 28 |  | 
|---|
| 29 |   public: | 
|---|
| 30 |     Player(); | 
|---|
| 31 |     Player(const char* fileName); | 
|---|
| 32 |     Player(const TiXmlElement* root); | 
|---|
| 33 |     virtual ~Player(); | 
|---|
| 34 |  | 
|---|
| 35 |     void init(); | 
|---|
| 36 |     void loadParams(const TiXmlElement* root); | 
|---|
| 37 |  | 
|---|
| 38 |     void addWeapon(Weapon* weapon); | 
|---|
| 39 |     void removeWeapon(Weapon* weapon); | 
|---|
| 40 |  | 
|---|
| 41 |     virtual void postSpawn(); | 
|---|
| 42 |     virtual void leftWorld(); | 
|---|
| 43 |     virtual void hit(WorldEntity* weapon, Vector* loc); | 
|---|
| 44 |     virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); | 
|---|
| 45 |  | 
|---|
| 46 |     virtual void tick(float time); | 
|---|
| 47 |     virtual void draw(); | 
|---|
| 48 |  | 
|---|
| 49 |     virtual void process(const Event &event); | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 |   private: | 
|---|
| 53 |     void move(float time); | 
|---|
| 54 |     void weaponAction(); | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 |   private: | 
|---|
| 58 |     bool                  bUp;                //!< up button pressed. | 
|---|
| 59 |     bool                  bDown;              //!< down button pressed. | 
|---|
| 60 |     bool                  bLeft;              //!< left button pressed. | 
|---|
| 61 |     bool                  bRight;             //!< right button pressed. | 
|---|
| 62 |     bool                  bAscend;            //!< ascend button pressed. | 
|---|
| 63 |     bool                  bDescend;           //!< descend button presses. | 
|---|
| 64 |     bool                  bFire;              //!< fire button pressed. | 
|---|
| 65 |  | 
|---|
| 66 |     WeaponManager*        weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping | 
|---|
| 67 |  | 
|---|
| 68 |     Vector*               velocity;           //!< the velocity of the player. | 
|---|
| 69 |     float                 travelSpeed;        //!< the current speed of the player (to make soft movement) | 
|---|
| 70 |     float                 acceleration;       //!< the acceleration of the player. | 
|---|
| 71 | }; | 
|---|
| 72 |  | 
|---|
| 73 | #endif /* _PLAYER_H */ | 
|---|