14 #include <vector> |
14 #include <vector> |
15 |
15 |
16 class Player : public PhysicsObject { |
16 class Player : public PhysicsObject { |
17 friend class Rope; |
17 friend class Rope; |
18 |
18 |
19 public: |
19 public: |
20 GameState &state; |
20 GameState &state; |
21 |
21 |
22 protected: |
22 protected: |
23 // XXX: not used |
23 // XXX: not used |
24 bool visible; |
24 bool visible; |
25 |
25 |
26 // our weapons |
26 // our weapons |
27 std::vector<Weapon*> weapons; |
27 std::vector<Weapon*> weapons; |
28 |
28 |
29 // the index of the currently selected weapon |
29 // the index of the currently selected weapon |
30 unsigned int selectedWeapon; |
30 unsigned int selectedWeapon; |
31 |
31 |
32 // we have a rope |
32 // we have a rope |
33 Rope rope; |
33 Rope rope; |
34 |
34 |
35 // XXX: hmm... updated where? |
35 // XXX: hmm... updated where? |
36 int animation_step; |
36 int animation_step; |
37 |
37 |
38 /** |
38 /** |
39 * Default constructor for use with virtual inheritance... it's not defined, and must not be called |
39 * Default constructor for use with virtual inheritance... it's not defined, and must not be called |
40 */ |
40 */ |
41 Player (void); |
41 Player (void); |
42 |
42 |
43 /** |
43 /** |
44 * Initialize params, and add ourselves to GameState |
44 * Initialize params, and add ourselves to GameState |
45 */ |
45 */ |
46 Player (GameState &state, Vector position, bool visible); |
46 Player (GameState &state, Vector position, bool visible); |
47 |
47 |
48 /** |
48 /** |
49 * Remove player from state players list |
49 * Remove player from state players list |
50 */ |
50 */ |
51 ~Player (void); |
51 ~Player (void); |
52 |
52 |
53 /* |
53 /* |
54 * Used by the network code to execute various actions |
54 * Used by the network code to execute various actions |
55 */ |
55 */ |
56 virtual void handleDig (Vector position, float radius); |
56 virtual void handleDig (Vector position, float radius); |
57 virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity); |
57 virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity); |
58 virtual void handleChangeWeapon (unsigned int weaponIndex); |
58 virtual void handleChangeWeapon (unsigned int weaponIndex); |
59 |
59 |
60 // Called by rope to handle state changes, these don't do anything by default |
60 // Called by rope to handle state changes, these don't do anything by default |
61 virtual void handleRopeState (RopeState state); |
61 virtual void handleRopeState (RopeState state); |
62 virtual void handleRopeLength (float length); |
62 virtual void handleRopeLength (float length); |
63 |
63 |
64 /* |
64 /* |
65 * The currently selected weapon |
65 * The currently selected weapon |
66 */ |
66 */ |
67 Weapon* getCurrentWeapon(); |
67 Weapon* getCurrentWeapon(); |
68 |
68 |
69 public: |
69 public: |
70 /* |
70 /* |
71 * Prints random things via Engine::log |
71 * Prints random things via Engine::log |
72 */ |
72 */ |
73 void printDebugInfo (); |
73 void printDebugInfo (); |
74 |
74 |
75 /* |
75 /* |
76 * Overrides PhysicsObject::tick to also advance game state |
76 * Overrides PhysicsObject::tick to also advance game state |
77 */ |
77 */ |
78 virtual void tick (TimeMS dt); |
78 virtual void tick (TimeMS dt); |
79 |
79 |
80 /* |
80 /* |
81 * Drawing requires the skin texture, which is loaded on-demand when draw is called |
81 * Drawing requires the skin texture, which is loaded on-demand when draw is called |
82 */ |
82 */ |
83 static bool skin_loaded; |
83 static bool skin_loaded; |
84 static CL_Surface skin_surface; |
84 static CL_Surface skin_surface; |
85 virtual void draw (Graphics *g, PixelCoordinate camera); |
85 virtual void draw (Graphics *g, PixelCoordinate camera); |
86 }; |
86 }; |
87 |
87 |
88 class LocalPlayer : public virtual Player { |
88 class LocalPlayer : public virtual Player { |
89 private: |
89 private: |
90 /* |
90 /* |
91 * Calculates projectil position/velocity and calls handleCreateProjectile |
91 * Calculates projectil position/velocity and calls handleCreateProjectile |
92 */ |
92 */ |
93 void fireWeapon (Weapon *weapon); |
93 void fireWeapon (Weapon *weapon); |
94 |
94 |
95 /* |
95 /* |
96 * Change weapon index, should be negative or positive 1 |
96 * Change weapon index, should be negative or positive 1 |
97 */ |
97 */ |
98 void changeWeapon (int delta); |
98 void changeWeapon (int delta); |
99 |
99 |
100 public: |
100 public: |
101 /* |
101 /* |
102 * Called to invoke some action on this player that we control, either by Graphics or NetworkServer. |
102 * Called to invoke some action on this player that we control, either by Graphics or NetworkServer. |
103 * |
103 * |
104 * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it |
104 * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it |
105 */ |
105 */ |
106 virtual void handleInput (PlayerInput input); |
106 virtual void handleInput (PlayerInput input, TimeMS dt); |
107 |
107 |
108 /* |
108 /* |
109 * As Player, but also draws the current weapon name if displayWeapon |
109 * As Player, but also draws the current weapon name if displayWeapon |
110 */ |
110 */ |
111 virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera); |
111 virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera); |
112 }; |
112 }; |
113 |
113 |
114 class RemotePlayer : public virtual Player { |
114 class RemotePlayer : public virtual Player { |
115 protected: |
115 protected: |
116 }; |
116 }; |
117 |
117 |
118 |
118 |
119 #endif |
119 #endif |