author | Tero Marttila <terom@fixme.fi> |
Fri, 16 Jan 2009 01:05:34 +0200 | |
changeset 398 | 306825786fba |
parent 309 | 05a39422c81e |
child 412 | 721c60072091 |
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" |
296
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
7 |
#include "Player.hh" |
197 | 8 |
#include "PhysicsObject.hh" |
208 | 9 |
#include "Timer.hh" |
296
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
10 |
#include "Types.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
|
11 |
#include "GraphicsPointer.hh" |
197 | 12 |
|
283
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
276
diff
changeset
|
13 |
/** |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
276
diff
changeset
|
14 |
* A projectile is a flying PhysicsObject, created by firing a player's weapon. It has an initial velocity, is |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
276
diff
changeset
|
15 |
* represented as a diamond-shape with the given "radius", can explode or bounce on collisions, expires at some point, |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
276
diff
changeset
|
16 |
* and can remove ground around it upon exploding. |
7540b0859579
start adding some documentation, most core classes (outside of Network) are now doxygen-enabled
terom
parents:
276
diff
changeset
|
17 |
*/ |
201 | 18 |
class Projectile : public PhysicsObject { |
197 | 19 |
protected: |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
20 |
/** |
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
272
diff
changeset
|
21 |
* Which player fired this projectile? |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
22 |
*/ |
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
272
diff
changeset
|
23 |
Player *player; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
24 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
25 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
26 |
* Projectiles can be inivisble, e.g. for digging |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
27 |
*/ |
197 | 28 |
bool visible; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
29 |
|
305 | 30 |
Weapon *weapon; |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
31 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
32 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
33 |
* The tick we were spawned at |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
34 |
*/ |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
35 |
TickCount birth_tick; |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
36 |
|
197 | 37 |
public: |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
38 |
/** |
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
272
diff
changeset
|
39 |
* Constructs this projectile using the given position/velocity, pulling the rest of the parameter values from the |
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
272
diff
changeset
|
40 |
* given weapon. The given player is assigned to this projectile. |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
41 |
*/ |
276
87434abc1ba1
ability to send NetworkObjectID's via packets, modify Network Projectiles to use this and fix recoil/reloading
terom
parents:
272
diff
changeset
|
42 |
Projectile (Player *player, Vector position, Vector velocity, Weapon *weapon, bool visible = true); |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
43 |
|
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 |
* Removes this from the world's list of projectiles |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
46 |
*/ |
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
|
47 |
virtual ~Projectile (void); |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
48 |
|
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
49 |
/** |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
50 |
* Draw |
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
51 |
*/ |
255
99431fdb0dc8
add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents:
252
diff
changeset
|
52 |
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
|
53 |
|
308
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
54 |
/** |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
55 |
* Get damage inflicted by this projectile. |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
56 |
* |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
57 |
* @return Damage inflicted by projectile. |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
58 |
*/ |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
59 |
Health getDamage (); |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
60 |
|
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
61 |
/** |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
62 |
* Adds one kill to projectile owner. |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
63 |
*/ |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
64 |
void addKillToOwner (); |
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
65 |
|
309 | 66 |
/** |
67 |
* Return the owner of the projectile. |
|
68 |
*/ |
|
69 |
const Player* getOwner (); |
|
70 |
||
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
|
71 |
protected: |
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
72 |
/** |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
73 |
* 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
|
74 |
* |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
75 |
* This is overriden by Network. |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
76 |
*/ |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
77 |
virtual void onDestroy (Vector position, bool removeGround); |
296
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
78 |
|
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
79 |
/** |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
80 |
* This Projectile has hit the given player. |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
81 |
* |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
82 |
* This Projectile inflicts a certain amount of damage on the player. We are not destroyed, this can be called |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
83 |
* multiple times... |
4d3ebaa29430
add separate Types.hh, and fix projectile-worm collisions on network
terom
parents:
283
diff
changeset
|
84 |
*/ |
308
60f4b55d5713
Calculates kills and deaths. You get frags by killing yourself \o/
saiam
parents:
305
diff
changeset
|
85 |
virtual void onHitPlayer (Player *player); |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
86 |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
87 |
/** |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
88 |
* Call onDestroy, removingGround |
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
89 |
*/ |
272 | 90 |
virtual void onCollision (Vector collisionPoint, PhysicsObject *other); |
224
e6faefba2ec1
fixed logger, and network projectiles should work reasonably well now
terom
parents:
223
diff
changeset
|
91 |
|
252
25054ce94d07
Rope is released if the ground on the pivot point is destroyed.
ekku
parents:
248
diff
changeset
|
92 |
/** |
271
bf6784a95b08
touch up weapon/projectile with comments and slight tweaking
terom
parents:
263
diff
changeset
|
93 |
* 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
|
94 |
*/ |
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
|
95 |
virtual void tick (TimeMS dt); |
197 | 96 |
}; |
97 |
||
98 |
#endif |