author | terom |
Mon, 08 Dec 2008 23:21:49 +0000 | |
changeset 328 | 51d644c8d5a2 |
parent 322 | f94a5c192097 |
child 412 | 721c60072091 |
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 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
12 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
13 |
* The rope can be in one of three states... |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
14 |
* |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
15 |
* @see Rope |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
16 |
*/ |
235 | 17 |
enum RopeState { |
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
18 |
ROPE_FOLDED, //<<< The rope is folded, out of sight, and not in use |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
19 |
ROPE_FLYING, //<<< The rope is flying through the air as a projectile |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
20 |
ROPE_FIXED //<<< The rope is attached to something |
235 | 21 |
}; |
225 | 22 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
23 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
24 |
* A rope is a PhysicsObject that can be thrown, whereupon it then flies until it hits something, whereupon |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
25 |
* it attaches to that, and sets itself as the player's pivot. |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
26 |
*/ |
225 | 27 |
class Rope : public PhysicsObject { |
273 | 28 |
private: |
328 | 29 |
/** the owner */ |
273 | 30 |
Player &player; |
235 | 31 |
|
328 | 32 |
/** How long is the rope in its unstreched state */ |
273 | 33 |
float length; |
235 | 34 |
|
328 | 35 |
/** Current state */ |
273 | 36 |
RopeState state; |
322 | 37 |
|
273 | 38 |
protected: |
39 |
/** |
|
40 |
* Attach the rope, so disable the PhysicsObject and change state |
|
41 |
* @param collisionPoint Where the rope has hit the ground. |
|
42 |
*/ |
|
43 |
virtual void onCollision (Vector collisionPoint, PhysicsObject *other); |
|
241 | 44 |
|
273 | 45 |
public: |
46 |
Rope(Player &player); |
|
235 | 47 |
|
328 | 48 |
/** |
273 | 49 |
* Throw the rope, so it flies up and away: o._-* |
50 |
*/ |
|
51 |
void throwRope (void); |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
52 |
|
328 | 53 |
/** |
273 | 54 |
* Release the rope, so if it's currently fixed or flying, then fold it |
55 |
*/ |
|
56 |
void release (void); |
|
57 |
||
328 | 58 |
/** |
273 | 59 |
* Climb up/down the rope |
60 |
*/ |
|
61 |
void changeLength (float delta); |
|
62 |
||
328 | 63 |
/** |
273 | 64 |
* Current state |
65 |
*/ |
|
66 |
RopeState getState (void); |
|
67 |
||
328 | 68 |
/** |
273 | 69 |
* Current length |
70 |
*/ |
|
71 |
float getLength (void); |
|
72 |
||
328 | 73 |
/** |
74 |
* If this Rope's player is pivoted to another player, return that player-pivot, else return NULL |
|
75 |
*/ |
|
76 |
Player *getPivotPlayer (void); |
|
77 |
||
273 | 78 |
/* |
79 |
* For use by NetworkClient |
|
80 |
*/ |
|
328 | 81 |
void updateState (RopeState state, Vector position, Vector velocity, float length, Player *pivot_player); |
273 | 82 |
void updateLength (float length); |
83 |
||
84 |
virtual void tick (TimeMS dt); |
|
85 |
||
86 |
/* |
|
87 |
* Just draws it |
|
88 |
*/ |
|
89 |
virtual void draw (Graphics *c, PixelCoordinate camera); |
|
225 | 90 |
}; |
91 |
||
92 |
#endif |