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