author | terom |
Sat, 06 Dec 2008 22:47:08 +0000 | |
changeset 233 | ff4ecea83cf5 |
parent 228 | dbc1bb7a98b5 |
child 235 | 0a0c729365ee |
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: |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
23 |
bool visible; |
212 | 24 |
std::vector<Weapon> arsenal; |
25 |
unsigned int selectedWeapon; //unsigned for x%sW not to fail |
|
213 | 26 |
bool changing; |
212 | 27 |
|
225 | 28 |
Rope rope; |
219 | 29 |
int animation_step; |
30 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
31 |
// 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
|
32 |
Player (void); |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
33 |
Player (GameState &state, Vector position, bool visible); |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
34 |
|
221 | 35 |
// used by the network code to execute actions for players |
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
36 |
virtual void handleDig (Vector position, float radius); |
223 | 37 |
virtual void handleCreateProjectile (Weapon &weapon, Vector position, Vector velocity); |
221 | 38 |
|
39 |
/* |
|
223 | 40 |
* The currently selected weapon |
221 | 41 |
*/ |
212 | 42 |
Weapon& getWeapon(); |
43 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
44 |
public: |
221 | 45 |
/* |
46 |
* Prints random things via Engine::log |
|
47 |
*/ |
|
48 |
void printDebugInfo (); |
|
49 |
||
50 |
/* |
|
51 |
* Overrides PhysicsObject::tick to also advance game state |
|
52 |
*/ |
|
53 |
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
|
54 |
|
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
55 |
/* |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
56 |
* 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
|
57 |
*/ |
1c92222af6d3
use Player static vars for texture loading, and load from the PROJECT_DATA_DIR path
terom
parents:
219
diff
changeset
|
58 |
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
|
59 |
static CL_Surface skin_surface; |
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
|
60 |
virtual void draw (Graphics *g); |
198 | 61 |
}; |
62 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
63 |
class LocalPlayer : public virtual Player { |
223 | 64 |
private: |
65 |
void fireWeapon (Weapon &weapon); |
|
66 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
67 |
public: |
221 | 68 |
/* |
69 |
* Called to invoke some action on this player that we control, either by Graphics or NetworkServer. |
|
70 |
* |
|
71 |
* NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it |
|
72 |
*/ |
|
73 |
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
|
74 |
|
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
|
75 |
/* |
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
|
76 |
* 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
|
77 |
*/ |
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
|
78 |
virtual void draw (Graphics *g, bool displayWeapon); |
198 | 79 |
}; |
80 |
||
209
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
81 |
class RemotePlayer : public virtual Player { |
68cc4248a508
sneak in some ugly ugly ugly Multiple Inheritance that hopefully nobody ever notices
terom
parents:
205
diff
changeset
|
82 |
protected: |
198 | 83 |
}; |
84 |
||
85 |
||
86 |
#endif |