1 | /*! |
---|
2 | \file projectile.h |
---|
3 | * a projectile, that is been shooted by a weapon |
---|
4 | |
---|
5 | You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the |
---|
6 | shooting funcions work, use the Projectile class. But if you want to implement your own shoots its |
---|
7 | different:<br> |
---|
8 | Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions |
---|
9 | - void tick() |
---|
10 | - void draw() |
---|
11 | - void hit() (only if you have working collision detection) |
---|
12 | When you have implemented these functions you have just to add the projectiles to your weapon. You ll want |
---|
13 | to make this by looking into the function |
---|
14 | - Weapon::fire() |
---|
15 | there you just change the line: |
---|
16 | Projectile* pj = new Projectile(); TO Projectile* pj = new MyOwnProjectileClass(); |
---|
17 | and schwups it works... :) |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _PROJECTILE_H |
---|
21 | #define _PROJECTILE_H |
---|
22 | |
---|
23 | #include "world_entity.h" |
---|
24 | #include "vector.h" |
---|
25 | |
---|
26 | class Vector; |
---|
27 | class Weapon; |
---|
28 | class ParticleEmitter; |
---|
29 | |
---|
30 | class Projectile : public WorldEntity |
---|
31 | { |
---|
32 | public: |
---|
33 | Projectile (Weapon* weapon); |
---|
34 | virtual ~Projectile (); |
---|
35 | |
---|
36 | void setFlightDirection(const Quaternion& flightDirection); |
---|
37 | void setVelocity(const Vector &velocity); |
---|
38 | void setLifeSpan(float lifeSpan); |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | virtual void destroy (); |
---|
44 | |
---|
45 | virtual void tick (float time); |
---|
46 | virtual void draw (); |
---|
47 | |
---|
48 | protected: |
---|
49 | |
---|
50 | // energy |
---|
51 | float energyMin; |
---|
52 | float energyMax; |
---|
53 | |
---|
54 | |
---|
55 | float lifeCycle; //!< The percentage of the Lifetime done [0-1] |
---|
56 | float lifeSpan; //!< The entire lifespan of the Shoot. in seconds |
---|
57 | |
---|
58 | Vector flightDirection; //!< direction in which the shoot flighs |
---|
59 | Weapon* weapon; //!< weapon the shoot belongs to. |
---|
60 | |
---|
61 | Vector velocity; //!< velocity of the projectile. |
---|
62 | |
---|
63 | ParticleEmitter* emitter; //!< For special effects each Projectile consists of an emitter. |
---|
64 | }; |
---|
65 | |
---|
66 | #endif /* _PROJECTILE_H */ |
---|