| 1 | /*! |
|---|
| 2 | \file player.h |
|---|
| 3 | \brief 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 World; |
|---|
| 18 | class Event; |
|---|
| 19 | |
|---|
| 20 | //! Basic controllable WorldEntity |
|---|
| 21 | class Player : public WorldEntity, public PhysicsInterface, public EventListener |
|---|
| 22 | { |
|---|
| 23 | friend class World; |
|---|
| 24 | |
|---|
| 25 | public: |
|---|
| 26 | Player(); |
|---|
| 27 | Player(const TiXmlElement* root); |
|---|
| 28 | virtual ~Player(); |
|---|
| 29 | |
|---|
| 30 | void init(); |
|---|
| 31 | void loadParams(const TiXmlElement* root); |
|---|
| 32 | |
|---|
| 33 | void addWeapon(Weapon* weapon); |
|---|
| 34 | void removeWeapon(Weapon* weapon); |
|---|
| 35 | |
|---|
| 36 | virtual void postSpawn(); |
|---|
| 37 | virtual void leftWorld(); |
|---|
| 38 | virtual void hit(WorldEntity* weapon, Vector* loc); |
|---|
| 39 | virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); |
|---|
| 40 | |
|---|
| 41 | virtual void tick(float time); |
|---|
| 42 | virtual void draw(); |
|---|
| 43 | |
|---|
| 44 | virtual void command(Command* cmd); |
|---|
| 45 | |
|---|
| 46 | virtual void process(const Event &event); |
|---|
| 47 | |
|---|
| 48 | private: |
|---|
| 49 | bool bUp; //!< up button pressed. |
|---|
| 50 | bool bDown; //!< down button pressed. |
|---|
| 51 | bool bLeft; //!< left button pressed. |
|---|
| 52 | bool bRight; //!< right button pressed. |
|---|
| 53 | bool bAscend; //!< ascend button pressed. |
|---|
| 54 | bool bDescend; //!< descend button presses. |
|---|
| 55 | bool bFire; //!< fire button pressed. |
|---|
| 56 | bool bWeaponChange; //!< weapon change button pressed |
|---|
| 57 | |
|---|
| 58 | tList<Weapon>* weapons;//!< a list of weapon |
|---|
| 59 | Weapon* activeWeapon; //!< the weapon that is currenty activated |
|---|
| 60 | Weapon* activeWeaponL; //temporary -- FIX THIS |
|---|
| 61 | WeaponManager* weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping |
|---|
| 62 | |
|---|
| 63 | World* myWorld; //!< reference to the world object |
|---|
| 64 | |
|---|
| 65 | Vector* velocity; //!< the velocity of the player. |
|---|
| 66 | float travelSpeed; //!< the current speed of the player (to make soft movement) |
|---|
| 67 | float acceleration; //!< the acceleration of the player. |
|---|
| 68 | |
|---|
| 69 | void move(float time); |
|---|
| 70 | void weapon(); |
|---|
| 71 | |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | #endif /* _PLAYER_H */ |
|---|