| author | nireco |
| Mon, 08 Dec 2008 21:49:54 +0000 | |
| changeset 315 | fe9da2d5355e |
| parent 305 | 56799ec8d7be |
| child 322 | f94a5c192097 |
| 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: |
29 |
// the owner |
|
30 |
Player &player; |
|
| 235 | 31 |
|
| 305 | 32 |
// possible pivot point (rope is stuck on a player) |
33 |
PhysicsObject *pivotObject; |
|
34 |
||
| 273 | 35 |
// How long is the rope in its unstrected state |
36 |
float length; |
|
| 235 | 37 |
|
| 273 | 38 |
// basic state |
39 |
RopeState state; |
|
40 |
||
41 |
protected: |
|
42 |
/** |
|
43 |
* Attach the rope, so disable the PhysicsObject and change state |
|
44 |
* @param collisionPoint Where the rope has hit the ground. |
|
45 |
*/ |
|
46 |
virtual void onCollision (Vector collisionPoint, PhysicsObject *other); |
|
| 241 | 47 |
|
| 273 | 48 |
/* |
49 |
* If the rope is currently longer than length, this returns ROPE_FORCE, else 0 |
|
50 |
*/ |
|
51 |
virtual float getPivotForce (PhysicsObject *bob); |
|
| 241 | 52 |
|
| 273 | 53 |
public: |
54 |
Rope(Player &player); |
|
| 235 | 55 |
|
| 273 | 56 |
/* |
57 |
* Throw the rope, so it flies up and away: o._-* |
|
58 |
*/ |
|
59 |
void throwRope (void); |
|
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
60 |
|
| 273 | 61 |
/* |
62 |
* Release the rope, so if it's currently fixed or flying, then fold it |
|
63 |
*/ |
|
64 |
void release (void); |
|
65 |
||
66 |
/* |
|
67 |
* Climb up/down the rope |
|
68 |
*/ |
|
69 |
void changeLength (float delta); |
|
70 |
||
71 |
/* |
|
72 |
* Current state |
|
73 |
*/ |
|
74 |
RopeState getState (void); |
|
75 |
||
76 |
/* |
|
77 |
* Current length |
|
78 |
*/ |
|
79 |
float getLength (void); |
|
80 |
||
81 |
/* |
|
82 |
* For use by NetworkClient |
|
83 |
*/ |
|
84 |
void updateState (RopeState state, Vector position, Vector velocity, float length); |
|
85 |
void updateLength (float length); |
|
86 |
||
87 |
virtual void tick (TimeMS dt); |
|
88 |
||
89 |
/* |
|
90 |
* Just draws it |
|
91 |
*/ |
|
92 |
virtual void draw (Graphics *c, PixelCoordinate camera); |
|
| 225 | 93 |
}; |
94 |
||
95 |
#endif |