author | Tero Marttila <terom@fixme.fi> |
Thu, 22 Jan 2009 04:24:26 +0200 | |
changeset 425 | 567144562978 |
parent 417 | c503e0c6a740 |
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 |
||
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
8 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
9 |
* 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
|
10 |
* |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
11 |
* @see Rope |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
12 |
*/ |
235 | 13 |
enum RopeState { |
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
14 |
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
|
15 |
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
|
16 |
ROPE_FIXED //<<< The rope is attached to something |
235 | 17 |
}; |
225 | 18 |
|
417
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
19 |
#include "Player.hh" |
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
20 |
#include "PhysicsObject.hh" |
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
21 |
|
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
22 |
#include "Graphics/Drawable.hh" |
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
23 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
24 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
273
diff
changeset
|
25 |
* 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
|
26 |
* 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
|
27 |
*/ |
225 | 28 |
class Rope : public PhysicsObject { |
273 | 29 |
private: |
328 | 30 |
/** the owner */ |
273 | 31 |
Player &player; |
235 | 32 |
|
328 | 33 |
/** How long is the rope in its unstreched state */ |
273 | 34 |
float length; |
235 | 35 |
|
328 | 36 |
/** Current state */ |
273 | 37 |
RopeState state; |
322 | 38 |
|
273 | 39 |
protected: |
40 |
/** |
|
41 |
* Attach the rope, so disable the PhysicsObject and change state |
|
42 |
* @param collisionPoint Where the rope has hit the ground. |
|
43 |
*/ |
|
44 |
virtual void onCollision (Vector collisionPoint, PhysicsObject *other); |
|
241 | 45 |
|
273 | 46 |
public: |
47 |
Rope(Player &player); |
|
235 | 48 |
|
328 | 49 |
/** |
273 | 50 |
* Throw the rope, so it flies up and away: o._-* |
51 |
*/ |
|
52 |
void throwRope (void); |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
53 |
|
328 | 54 |
/** |
273 | 55 |
* Release the rope, so if it's currently fixed or flying, then fold it |
56 |
*/ |
|
57 |
void release (void); |
|
58 |
||
328 | 59 |
/** |
273 | 60 |
* Climb up/down the rope |
61 |
*/ |
|
62 |
void changeLength (float delta); |
|
63 |
||
328 | 64 |
/** |
273 | 65 |
* Current state |
66 |
*/ |
|
67 |
RopeState getState (void); |
|
68 |
||
328 | 69 |
/** |
273 | 70 |
* Current length |
71 |
*/ |
|
72 |
float getLength (void); |
|
73 |
||
328 | 74 |
/** |
75 |
* If this Rope's player is pivoted to another player, return that player-pivot, else return NULL |
|
76 |
*/ |
|
77 |
Player *getPivotPlayer (void); |
|
78 |
||
273 | 79 |
/* |
80 |
* For use by NetworkClient |
|
81 |
*/ |
|
328 | 82 |
void updateState (RopeState state, Vector position, Vector velocity, float length, Player *pivot_player); |
273 | 83 |
void updateLength (float length); |
84 |
||
85 |
virtual void tick (TimeMS dt); |
|
86 |
||
417
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
87 |
#if GRAPHICS_ENABLED |
273 | 88 |
/* |
412
721c60072091
new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents:
328
diff
changeset
|
89 |
* Draw the rope, in the FLYING/FIXED state |
273 | 90 |
*/ |
412
721c60072091
new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents:
328
diff
changeset
|
91 |
virtual void draw (graphics::Display &display, PixelCoordinate camera); |
417
c503e0c6a740
support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
Tero Marttila <terom@fixme.fi>
parents:
412
diff
changeset
|
92 |
#endif |
225 | 93 |
}; |
94 |
||
95 |
#endif |