| author | saiam |
| Mon, 08 Dec 2008 00:05:45 +0000 | |
| changeset 273 | eeb699e1d908 |
| parent 272 | 97de051edbcf |
| child 276 | 87434abc1ba1 |
| permissions | -rw-r--r-- |
| 197 | 1 |
#ifndef PROJECTILE_HH |
2 |
#define PROJECTILE_HH |
|
3 |
||
| 201 | 4 |
class Projectile; |
| 197 | 5 |
|
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
211
diff
changeset
|
6 |
#include "GameState.hh" |
| 197 | 7 |
#include "PhysicsObject.hh" |
| 208 | 8 |
#include "Timer.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:
224
diff
changeset
|
9 |
#include "GraphicsPointer.hh" |
| 197 | 10 |
|
| 201 | 11 |
class Projectile : public PhysicsObject {
|
| 197 | 12 |
protected: |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
13 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
14 |
* Reference to the world that we live in |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
15 |
*/ |
| 197 | 16 |
GameState &state; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
17 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
18 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
19 |
* Projectiles can be inivisble, e.g. for digging |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
20 |
*/ |
| 197 | 21 |
bool visible; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
22 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
23 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
24 |
* The projectile is diamond-shaped, and this is the dimanond's "radius" |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
25 |
*/ |
| 208 | 26 |
float radius; |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
27 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
28 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
29 |
* The radius of earth removed by this projectile on impact |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
30 |
*/ |
|
263
8c999cf4c182
weapon projectile radiuses and fix network play (local_player == NULL, Rope releasing upon being hit
terom
parents:
255
diff
changeset
|
31 |
float explosionRadius; |
| 223 | 32 |
|
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
33 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
34 |
* How many ticks this projectile lasts before being expiring |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
35 |
*/ |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
36 |
TickCount expire; |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
37 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
38 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
39 |
* The tick we were spawned at |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
40 |
*/ |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
41 |
TickCount birth_tick; |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
42 |
|
| 197 | 43 |
public: |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
44 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
45 |
* Construct a Projectile using the given parameters and add it to the world's list of projectiles |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
46 |
*/ |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
47 |
Projectile (GameState &state, Vector position, Vector velocity, float explosionRadius, float radius, |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
48 |
TickCount expire, bool visible = true); |
| 208 | 49 |
|
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
50 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
51 |
* Like above, but using the parameters of the given weapon |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
52 |
* |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
53 |
* @see Projectile |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
54 |
*/ |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
55 |
Projectile (GameState &state, Vector position, Vector velocity, Weapon *weapon, bool visible = true); |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
56 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
57 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
58 |
* Removes this from the world's list of projectiles |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
59 |
*/ |
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
211
diff
changeset
|
60 |
virtual ~Projectile (void); |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
61 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
62 |
/** |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
63 |
* Draw |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
64 |
*/ |
|
255
99431fdb0dc8
add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents:
252
diff
changeset
|
65 |
virtual void draw (Graphics *g, PixelCoordinate camera) const; |
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
211
diff
changeset
|
66 |
|
|
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
211
diff
changeset
|
67 |
protected: |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
68 |
/** |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
69 |
* Initialize shape and add to world projectiles list |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
70 |
*/ |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
71 |
void initialize (void); |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
72 |
|
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
73 |
/** |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
74 |
* Removes ground at given position if applicable, and destroys this PhysicsObject. |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
75 |
* |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
76 |
* This is overriden by Network. |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
77 |
*/ |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
78 |
virtual void onDestroy (Vector position, bool removeGround); |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
79 |
|
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
80 |
/** |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
81 |
* Call onDestroy, removingGround |
|
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
82 |
*/ |
| 272 | 83 |
virtual void onCollision (Vector collisionPoint, PhysicsObject *other); |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
84 |
|
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
85 |
/** |
|
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
86 |
* If we have expired, call onDestory and removeGround |
|
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
87 |
*/ |
|
222
293ddf4c067d
reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents:
211
diff
changeset
|
88 |
virtual void tick (TimeMS dt); |
| 197 | 89 |
}; |
90 |
||
91 |
#endif |