author | nireco |
Sun, 07 Dec 2008 18:23:18 +0000 | |
changeset 248 | e40ef56dc62c |
parent 241 | e95b1602d836 |
child 252 | 25054ce94d07 |
permissions | -rw-r--r-- |
225 | 1 |
#ifndef ROPE_HH |
2 |
#define ROPE_HH |
|
3 |
||
4 |
// Pre-declarations since rope wants to know the Player |
|
5 |
// and the Player wants to know the rope. |
|
6 |
class Rope; |
|
7 |
||
8 |
#include "Player.hh" |
|
9 |
#include "PhysicsObject.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:
231
diff
changeset
|
10 |
#include "GraphicsPointer.hh" |
225 | 11 |
|
235 | 12 |
enum RopeState { |
13 |
ROPE_FOLDED, |
|
14 |
ROPE_FLYING, |
|
15 |
ROPE_FIXED |
|
16 |
}; |
|
225 | 17 |
|
18 |
class Rope : public PhysicsObject { |
|
235 | 19 |
private: |
20 |
// the owner |
|
21 |
Player &player; |
|
228 | 22 |
|
235 | 23 |
// How long is the rope in its unstrected state |
24 |
float length; |
|
25 |
||
26 |
// basic state |
|
27 |
RopeState state; |
|
28 |
||
29 |
protected: |
|
30 |
/* |
|
31 |
* Attach the rope, so disable the PhysicsObject and change state |
|
32 |
*/ |
|
33 |
virtual void onCollision (void); |
|
225 | 34 |
|
235 | 35 |
/* |
36 |
* If the rope is currently longer than length, this returns ROPE_FORCE, else 0 |
|
37 |
*/ |
|
38 |
virtual float getPivotForce (PhysicsObject *bob); |
|
39 |
||
40 |
public: |
|
41 |
Rope(Player &player); |
|
42 |
||
43 |
/* |
|
44 |
* Throw the rope, so it flies up and away: o._-* |
|
45 |
*/ |
|
46 |
void throwRope (void); |
|
47 |
||
48 |
/* |
|
49 |
* Release the rope, so if it's currently fixed or flying, then fold it |
|
50 |
*/ |
|
51 |
void release (void); |
|
52 |
||
53 |
/* |
|
54 |
* Climb up/down the rope |
|
55 |
*/ |
|
56 |
void changeLength (float delta); |
|
57 |
||
58 |
/* |
|
59 |
* Current state |
|
60 |
*/ |
|
61 |
RopeState getState (void); |
|
241 | 62 |
|
63 |
/* |
|
64 |
* Current length |
|
65 |
*/ |
|
66 |
float getLength (void); |
|
67 |
||
68 |
/* |
|
69 |
* For use by NetworkClient |
|
70 |
*/ |
|
71 |
void updateState (RopeState state, Vector position, Vector velocity, float length); |
|
72 |
void updateLength (float length); |
|
235 | 73 |
|
74 |
/* |
|
75 |
* Just draws it |
|
76 |
*/ |
|
248 | 77 |
virtual void draw (Graphics *c, Vector camera = Vector(0, 0)) const; |
225 | 78 |
}; |
79 |
||
80 |
#endif |