[5996] | 1 | |
---|
| 2 | /*! |
---|
[9045] | 3 | * @file spacecraft_2d.h |
---|
| 4 | * Implements the Control of a Spacecraft2D |
---|
[5996] | 5 | */ |
---|
| 6 | |
---|
[9045] | 7 | #ifndef _SPACECRAFT_2D_H |
---|
| 8 | #define _SPACECRAFT_2D_H |
---|
[5996] | 9 | |
---|
| 10 | #include "playable.h" |
---|
| 11 | |
---|
[7001] | 12 | // Forward Declaration |
---|
| 13 | class ParticleEmitter; |
---|
| 14 | class ParticleSystem; |
---|
| 15 | |
---|
[9045] | 16 | class Spacecraft2D : public Playable |
---|
[5996] | 17 | { |
---|
[9869] | 18 | ObjectListDeclaration(Spacecraft2D); |
---|
[5996] | 19 | public: |
---|
[9045] | 20 | Spacecraft2D(const std::string& fileName); |
---|
| 21 | Spacecraft2D(const TiXmlElement* root = NULL); |
---|
| 22 | virtual ~Spacecraft2D(); |
---|
[5996] | 23 | |
---|
[6512] | 24 | virtual void loadParams(const TiXmlElement* root); |
---|
[9110] | 25 | |
---|
[9052] | 26 | void setTravelSpeed(float travelSpeed); |
---|
[9110] | 27 | void setTravelHeight(float travelHeight); |
---|
| 28 | void setTravelDistance(const Vector2D& distance); |
---|
| 29 | void setTravelDistance(float x, float y); |
---|
[9052] | 30 | |
---|
[9235] | 31 | void setAirFriction(float friction) { this->airFriction = friction; }; |
---|
[9110] | 32 | |
---|
[9235] | 33 | |
---|
[9110] | 34 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); |
---|
[6222] | 35 | virtual void enter(); |
---|
| 36 | virtual void leave(); |
---|
| 37 | |
---|
[9052] | 38 | |
---|
[5996] | 39 | virtual void postSpawn(); |
---|
| 40 | virtual void leftWorld(); |
---|
| 41 | |
---|
| 42 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
[6806] | 43 | virtual void tick(float dt); |
---|
[6005] | 44 | virtual void draw() const; |
---|
[5996] | 45 | |
---|
| 46 | virtual void process(const Event &event); |
---|
| 47 | |
---|
[9110] | 48 | protected: |
---|
| 49 | virtual void enterPlaymode(Playable::Playmode playmode); |
---|
| 50 | |
---|
[5996] | 51 | private: |
---|
[6803] | 52 | void init(); |
---|
[6806] | 53 | void movement(float dt); |
---|
[6803] | 54 | |
---|
| 55 | private: |
---|
[6805] | 56 | bool bForward; //!< forward button pressed. |
---|
| 57 | bool bBackward; //!< backward button pressed. |
---|
[5996] | 58 | bool bLeft; //!< left button pressed. |
---|
| 59 | bool bRight; //!< right button pressed. |
---|
| 60 | |
---|
[6637] | 61 | int yInvert; |
---|
[5996] | 62 | float mouseSensitivity; //!< the mouse sensitivity |
---|
[6799] | 63 | |
---|
[9110] | 64 | /// Normal Movement. |
---|
| 65 | Quaternion direction; //!< the direction of the Spacecraft2D. |
---|
| 66 | float acceleration; //!< the acceleration of the Spacecraft2D. |
---|
| 67 | float airFriction; //!< AirFriction. |
---|
| 68 | float airViscosity; |
---|
[9052] | 69 | |
---|
| 70 | |
---|
[9110] | 71 | /// 2D-traveling |
---|
| 72 | PNode* travelNode; |
---|
| 73 | float* toTravelHeight; |
---|
| 74 | float travelSpeed; //!< the current speed of the Hove (to make soft movement) |
---|
| 75 | |
---|
| 76 | Vector2D travelDistance; //!< Travel-Distance away from the TravelNode. |
---|
| 77 | |
---|
| 78 | /// Camera |
---|
| 79 | PNode cameraNode; |
---|
[6807] | 80 | float cameraLook; |
---|
| 81 | float rotation; |
---|
[5996] | 82 | |
---|
[6222] | 83 | |
---|
[9046] | 84 | ParticleEmitter* burstEmitter; |
---|
[7001] | 85 | ParticleSystem* burstSystem; |
---|
[5996] | 86 | }; |
---|
| 87 | |
---|
[9045] | 88 | #endif /* _SPACECRAFT_2DS_H */ |
---|