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 | |
---|
31 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); |
---|
32 | virtual void enter(); |
---|
33 | virtual void leave(); |
---|
34 | |
---|
35 | |
---|
36 | virtual void postSpawn(); |
---|
37 | virtual void leftWorld(); |
---|
38 | |
---|
39 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
40 | virtual void tick(float dt); |
---|
41 | virtual void draw() const; |
---|
42 | |
---|
43 | virtual void process(const Event &event); |
---|
44 | |
---|
45 | protected: |
---|
46 | virtual void enterPlaymode(Playable::Playmode playmode); |
---|
47 | |
---|
48 | private: |
---|
49 | void init(); |
---|
50 | void movement(float dt); |
---|
51 | |
---|
52 | private: |
---|
53 | bool bForward; //!< forward button pressed. |
---|
54 | bool bBackward; //!< backward button pressed. |
---|
55 | bool bLeft; //!< left button pressed. |
---|
56 | bool bRight; //!< right button pressed. |
---|
57 | |
---|
58 | int yInvert; |
---|
59 | float mouseSensitivity; //!< the mouse sensitivity |
---|
60 | |
---|
61 | /// Normal Movement. |
---|
62 | Quaternion direction; //!< the direction of the Spacecraft2D. |
---|
63 | float acceleration; //!< the acceleration of the Spacecraft2D. |
---|
64 | float airFriction; //!< AirFriction. |
---|
65 | |
---|
66 | float airViscosity; |
---|
67 | |
---|
68 | |
---|
69 | /// 2D-traveling |
---|
70 | PNode* travelNode; |
---|
71 | float* toTravelHeight; |
---|
72 | float travelSpeed; //!< the current speed of the Hove (to make soft movement) |
---|
73 | |
---|
74 | Vector2D travelDistance; //!< Travel-Distance away from the TravelNode. |
---|
75 | |
---|
76 | /// Camera |
---|
77 | PNode cameraNode; |
---|
78 | float cameraLook; |
---|
79 | float rotation; |
---|
80 | |
---|
81 | |
---|
82 | ParticleEmitter* burstEmitter; |
---|
83 | ParticleSystem* burstSystem; |
---|
84 | }; |
---|
85 | |
---|
86 | #endif /* _SPACECRAFT_2DS_H */ |
---|