| 1 | /*! |
|---|
| 2 | * @file space_ship.h |
|---|
| 3 | * Implements the Control of a Spaceship |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _SPACE_SHIP_H |
|---|
| 7 | #define _SPACE_SHIP_H |
|---|
| 8 | |
|---|
| 9 | #include "playable.h" |
|---|
| 10 | #include "extendable.h" |
|---|
| 11 | |
|---|
| 12 | // Forward Declaration |
|---|
| 13 | template<class T> class tList; |
|---|
| 14 | class Vector; |
|---|
| 15 | class Event; |
|---|
| 16 | class ParticleEmitter; |
|---|
| 17 | class ParticleSystem; |
|---|
| 18 | |
|---|
| 19 | class SpaceShip : public Playable |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | public: |
|---|
| 23 | SpaceShip(const std::string& fileName); |
|---|
| 24 | SpaceShip(const TiXmlElement* root = NULL); |
|---|
| 25 | virtual ~SpaceShip(); |
|---|
| 26 | |
|---|
| 27 | virtual void loadParams(const TiXmlElement* root); |
|---|
| 28 | |
|---|
| 29 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); |
|---|
| 30 | |
|---|
| 31 | virtual void enter(); |
|---|
| 32 | virtual void leave(); |
|---|
| 33 | |
|---|
| 34 | virtual void reset(); |
|---|
| 35 | |
|---|
| 36 | virtual void postSpawn(); |
|---|
| 37 | virtual void leftWorld(); |
|---|
| 38 | |
|---|
| 39 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
|---|
| 40 | virtual void tick(float time); |
|---|
| 41 | virtual void draw() const; |
|---|
| 42 | |
|---|
| 43 | virtual void process(const Event &event); |
|---|
| 44 | |
|---|
| 45 | private: |
|---|
| 46 | void init(); |
|---|
| 47 | |
|---|
| 48 | void calculateVelocity(float time); |
|---|
| 49 | |
|---|
| 50 | bool bUp; //!< up button pressed. |
|---|
| 51 | bool bDown; //!< down button pressed. |
|---|
| 52 | bool bLeft; //!< left button pressed. |
|---|
| 53 | bool bRight; //!< right button pressed. |
|---|
| 54 | bool bAscend; //!< ascend button pressed. |
|---|
| 55 | bool bDescend; //!< descend button presses. |
|---|
| 56 | // bool bFire; //!< fire button pressed.(moved to playable) |
|---|
| 57 | bool bRollL; //!< rolling button pressed (left) |
|---|
| 58 | bool bRollR; //!< rolling button pressed (right) |
|---|
| 59 | |
|---|
| 60 | float xMouse; //!< mouse moved in x-Direction |
|---|
| 61 | float yMouse; //!< mouse moved in y-Direction |
|---|
| 62 | float mouseSensitivity; //!< the mouse sensitivity |
|---|
| 63 | int yInvert; |
|---|
| 64 | int controlVelocityX; |
|---|
| 65 | int controlVelocityY; |
|---|
| 66 | // float cycle; //!< hovercycle |
|---|
| 67 | |
|---|
| 68 | Vector velocity; //!< the velocity of the player. |
|---|
| 69 | Vector oldVelocity; //!< the velocity the player had last synced |
|---|
| 70 | Quaternion mouseDir; //!< the direction where the player wants to fly |
|---|
| 71 | Quaternion oldMouseDir; //!< the direction where the player wanted to fly |
|---|
| 72 | float shipInertia; //!< the inertia of the ship(how fast the ship reacts to a mouse input) |
|---|
| 73 | Quaternion rotQuat; |
|---|
| 74 | Quaternion pitchDir; |
|---|
| 75 | float travelSpeed; //!< the current speed of the player (to make soft movement) |
|---|
| 76 | float acceleration; //!< the acceleration of the player. |
|---|
| 77 | |
|---|
| 78 | float airViscosity; |
|---|
| 79 | |
|---|
| 80 | byte oldMask; //!< used for synchronisation |
|---|
| 81 | |
|---|
| 82 | ParticleEmitter* burstEmitter; |
|---|
| 83 | ParticleSystem* burstSystem; |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | #endif /* _SPACE_SHIPS_H */ |
|---|