author | terom |
Sun, 07 Dec 2008 20:07:28 +0000 | |
changeset 255 | 99431fdb0dc8 |
parent 252 | 25054ce94d07 |
child 273 | eeb699e1d908 |
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: |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
30 |
/** |
235 | 31 |
* Attach the rope, so disable the PhysicsObject and change state |
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
32 |
* @param collisionPoint Where the rope has hit the ground. |
235 | 33 |
*/ |
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
34 |
virtual void onCollision (Vector collisionPoint); |
225 | 35 |
|
235 | 36 |
/* |
37 |
* If the rope is currently longer than length, this returns ROPE_FORCE, else 0 |
|
38 |
*/ |
|
39 |
virtual float getPivotForce (PhysicsObject *bob); |
|
40 |
||
41 |
public: |
|
42 |
Rope(Player &player); |
|
43 |
||
44 |
/* |
|
45 |
* Throw the rope, so it flies up and away: o._-* |
|
46 |
*/ |
|
47 |
void throwRope (void); |
|
48 |
||
49 |
/* |
|
50 |
* Release the rope, so if it's currently fixed or flying, then fold it |
|
51 |
*/ |
|
52 |
void release (void); |
|
53 |
||
54 |
/* |
|
55 |
* Climb up/down the rope |
|
56 |
*/ |
|
57 |
void changeLength (float delta); |
|
58 |
||
59 |
/* |
|
60 |
* Current state |
|
61 |
*/ |
|
62 |
RopeState getState (void); |
|
241 | 63 |
|
64 |
/* |
|
65 |
* Current length |
|
66 |
*/ |
|
67 |
float getLength (void); |
|
68 |
||
69 |
/* |
|
70 |
* For use by NetworkClient |
|
71 |
*/ |
|
72 |
void updateState (RopeState state, Vector position, Vector velocity, float length); |
|
73 |
void updateLength (float length); |
|
235 | 74 |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
75 |
virtual void tick (TimeMS dt); |
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
76 |
|
235 | 77 |
/* |
78 |
* Just draws it |
|
79 |
*/ |
|
255
99431fdb0dc8
add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents:
252
diff
changeset
|
80 |
virtual void draw (Graphics *c, PixelCoordinate camera); |
225 | 81 |
}; |
82 |
||
83 |
#endif |