[3573] | 1 | /*! |
---|
| 2 | \projectile.h |
---|
| 3 | \brief 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 |
---|
| 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... :) |
---|
[3573] | 18 | */ |
---|
| 19 | |
---|
| 20 | #ifndef _PROJECTILE_H |
---|
| 21 | #define _PROJECTILE_H |
---|
| 22 | |
---|
| 23 | #include "world_entity.h" |
---|
| 24 | |
---|
[3632] | 25 | class Vector; |
---|
[3683] | 26 | class Weapon; |
---|
[3573] | 27 | |
---|
| 28 | class Projectile : public WorldEntity |
---|
| 29 | { |
---|
| 30 | friend class World; |
---|
| 31 | |
---|
| 32 | public: |
---|
[3683] | 33 | Projectile (Weapon* weapon); |
---|
[3573] | 34 | virtual ~Projectile (); |
---|
| 35 | |
---|
[3708] | 36 | void setFlightDirection(Quaternion flightDirection); |
---|
[3646] | 37 | void setSpeed(float speed); |
---|
| 38 | void setTTL(float ttl); |
---|
[3632] | 39 | |
---|
[3578] | 40 | virtual void hit (WorldEntity* weapon, Vector* loc); |
---|
| 41 | virtual void destroy (); |
---|
| 42 | |
---|
[3573] | 43 | virtual void tick (float time); |
---|
| 44 | virtual void draw (); |
---|
| 45 | |
---|
[3710] | 46 | protected: |
---|
[3583] | 47 | //physical attriutes like: force, speed, acceleration etc. |
---|
[3632] | 48 | float speed; //!< this is the speed of the projectile |
---|
[3646] | 49 | float currentLifeTime; //!< this is the time, the projectile exists in this world (incremented by tick) |
---|
| 50 | float ttl; //!< time to life, after this time, the projectile will garbage collect itself |
---|
[3632] | 51 | Vector* flightDirection; //!< direction in which the shoot flights |
---|
[3683] | 52 | Weapon* weapon; //!< weapon the shoot belongs to |
---|
[3646] | 53 | |
---|
[3573] | 54 | }; |
---|
| 55 | |
---|
| 56 | #endif /* _PROJECTILE_H */ |
---|