author | saiam |
Sun, 07 Dec 2008 19:40:40 +0000 | |
changeset 251 | 6a6208e5c7a1 |
parent 248 | e40ef56dc62c |
child 255 | 99431fdb0dc8 |
permissions | -rw-r--r-- |
198 | 1 |
#ifndef PLAYER_HH |
2 |
#define PLAYER_HH |
|
3 |
||
4 |
class Player; |
|
199 | 5 |
class LocalPlayer; |
6 |
class RemotePlayer; |
|
198 | 7 |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
8 |
#include "Weapon.hh" |
199 | 9 |
#include "GameState.hh" |
198 | 10 |
#include "PhysicsObject.hh" |
205 | 11 |
#include "Input.hh" |
225 | 12 |
#include "Rope.hh" |
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
13 |
#include "GraphicsPointer.hh" |
212 | 14 |
#include <vector> |
198 | 15 |
|
16 |
class Player : public PhysicsObject { |
|
228 | 17 |
friend class Rope; |
18 |
||
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
221
diff
changeset
|
19 |
public: |
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
221
diff
changeset
|
20 |
GameState &state; |
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
221
diff
changeset
|
21 |
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
22 |
protected: |
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
23 |
// XXX: not used |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
24 |
bool visible; |
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
25 |
|
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
26 |
// our weapons |
236 | 27 |
std::vector<Weapon*> weapons; |
212 | 28 |
|
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
29 |
// the index of the currently selected weapon |
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
30 |
unsigned int selectedWeapon; |
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
31 |
|
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
32 |
// we have a rope |
225 | 33 |
Rope rope; |
239
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
34 |
|
550397d9d479
implement network weapon changes and fix weapon firing
terom
parents:
237
diff
changeset
|
35 |
// XXX: hmm... updated where? |
219 | 36 |
int animation_step; |
37 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
38 |
// default constructor for use with virtual inheritance... it's not defined |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
39 |
Player (void); |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
40 |
Player (GameState &state, Vector position, bool visible); |
236 | 41 |
|
241 | 42 |
/* |
43 |
* Used by the network code to execute various actions |
|
44 |
*/ |
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
45 |
virtual void handleDig (Vector position, float radius); |
236 | 46 |
virtual void handleCreateProjectile (Weapon *weapon, Vector position, Vector velocity); |
237 | 47 |
virtual void handleChangeWeapon (unsigned int weaponIndex); |
241 | 48 |
|
49 |
// Called by rope to handle state changes, these don't do anything by default |
|
50 |
virtual void handleRopeState (RopeState state); |
|
51 |
virtual void handleRopeLength (float length); |
|
221 | 52 |
|
53 |
/* |
|
223 | 54 |
* The currently selected weapon |
221 | 55 |
*/ |
236 | 56 |
Weapon* getCurrentWeapon(); |
212 | 57 |
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
58 |
public: |
221 | 59 |
/* |
60 |
* Prints random things via Engine::log |
|
61 |
*/ |
|
62 |
void printDebugInfo (); |
|
63 |
||
64 |
/* |
|
65 |
* Overrides PhysicsObject::tick to also advance game state |
|
66 |
*/ |
|
67 |
virtual void tick (TimeMS dt); |
|
220
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
68 |
|
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
69 |
/* |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
70 |
* Drawing requires the skin texture, which is loaded on-demand when draw is called |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
71 |
*/ |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
72 |
static bool skin_loaded; |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
73 |
static CL_Surface skin_surface; |
248 | 74 |
virtual void draw (Graphics *g, Vector camera = Vector(0, 0)); |
198 | 75 |
}; |
76 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
77 |
class LocalPlayer : public virtual Player { |
223 | 78 |
private: |
236 | 79 |
/* |
80 |
* Calculates projectil position/velocity and calls handleCreateProjectile |
|
81 |
*/ |
|
82 |
void fireWeapon (Weapon *weapon); |
|
237 | 83 |
|
84 |
/* |
|
85 |
* Change weapon index, should be negative or positive 1 |
|
86 |
*/ |
|
87 |
void changeWeapon (int delta); |
|
223 | 88 |
|
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
89 |
public: |
221 | 90 |
/* |
91 |
* Called to invoke some action on this player that we control, either by Graphics or NetworkServer. |
|
92 |
* |
|
93 |
* NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it |
|
94 |
*/ |
|
95 |
virtual void handleInput (PlayerInput input); |
|
233
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
96 |
|
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
97 |
/* |
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
98 |
* As Player, but also draws the current weapon name if displayWeapon |
ff4ecea83cf5
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
terom
parents:
228
diff
changeset
|
99 |
*/ |
248 | 100 |
virtual void draw (Graphics *g, bool displayWeapon, Vector camera); |
198 | 101 |
}; |
102 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
103 |
class RemotePlayer : public virtual Player { |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
104 |
protected: |
198 | 105 |
}; |
106 |
||
107 |
||
108 |
#endif |