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