[4597] | 1 | /*! |
---|
[5039] | 2 | * @file projectile.h |
---|
[4836] | 3 | * a projectile, that is been shooted by a weapon |
---|
[3710] | 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 |
---|
[4597] | 6 | shooting funcions work, use the Projectile class. But if you want to implement your own shoots its |
---|
[3710] | 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) |
---|
[4597] | 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 |
---|
[3710] | 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... :) |
---|
[3573] | 18 | */ |
---|
| 19 | |
---|
| 20 | #ifndef _PROJECTILE_H |
---|
| 21 | #define _PROJECTILE_H |
---|
| 22 | |
---|
| 23 | #include "world_entity.h" |
---|
| 24 | |
---|
[5447] | 25 | class FastFactory; |
---|
| 26 | |
---|
[4597] | 27 | class Projectile : public WorldEntity |
---|
[3573] | 28 | { |
---|
[4890] | 29 | public: |
---|
[4932] | 30 | Projectile (); |
---|
[4890] | 31 | virtual ~Projectile (); |
---|
[3573] | 32 | |
---|
[4927] | 33 | void setFlightDirection(const Quaternion& flightDirection); |
---|
[4890] | 34 | void setVelocity(const Vector &velocity); |
---|
| 35 | void setLifeSpan(float lifeSpan); |
---|
[3573] | 36 | |
---|
[3632] | 37 | |
---|
[4948] | 38 | void setEnergies(float energyMin, float energyMax); |
---|
| 39 | /** @returns the minimal charched energy */ |
---|
| 40 | inline float getEnergyMin() { return this->energyMin; }; |
---|
| 41 | /** @returns the maximal charched energy */ |
---|
| 42 | inline float getEnergyMax() { return this->energyMax; }; |
---|
| 43 | /** @returns if the Projectile can be charged */ |
---|
| 44 | inline bool isChageable() { return this->bChargeable; }; |
---|
[3578] | 45 | |
---|
[3573] | 46 | |
---|
[5443] | 47 | /** @brief This is called, when the Projectile is Emitted */ |
---|
| 48 | virtual void activate() = 0; |
---|
| 49 | /** @brief This is called, when the Projectile is being destroyed, or deleted */ |
---|
| 50 | virtual void deactivate() = 0; |
---|
[4948] | 51 | |
---|
[4890] | 52 | virtual void destroy (); |
---|
[4597] | 53 | |
---|
[4890] | 54 | virtual void tick (float time); |
---|
| 55 | virtual void draw (); |
---|
| 56 | |
---|
| 57 | protected: |
---|
| 58 | // energy |
---|
| 59 | float energyMin; |
---|
| 60 | float energyMax; |
---|
[4948] | 61 | bool bChargeable; //!< if the Projectile is Charegeable |
---|
[4890] | 62 | |
---|
| 63 | float lifeCycle; //!< The percentage of the Lifetime done [0-1] |
---|
[4927] | 64 | float lifeSpan; //!< The entire lifespan of the Shoot. in seconds |
---|
[4890] | 65 | |
---|
[4948] | 66 | Vector flightDirection; //!< DOF direction in which the shoot flighs |
---|
[4890] | 67 | |
---|
| 68 | Vector velocity; //!< velocity of the projectile. |
---|
[3573] | 69 | }; |
---|
| 70 | |
---|
| 71 | #endif /* _PROJECTILE_H */ |
---|