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 destroy(); |
---|
40 | virtual void respawn(); |
---|
41 | |
---|
42 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
43 | virtual void tick(float time); |
---|
44 | virtual void draw() const; |
---|
45 | |
---|
46 | virtual void process(const Event &event); |
---|
47 | |
---|
48 | private: |
---|
49 | void init(); |
---|
50 | |
---|
51 | void calculateVelocity(float time); |
---|
52 | |
---|
53 | bool bUp; //!< up button pressed. |
---|
54 | bool bDown; //!< down button pressed. |
---|
55 | bool bLeft; //!< left button pressed. |
---|
56 | bool bRight; //!< right button pressed. |
---|
57 | bool bAscend; //!< ascend button pressed. |
---|
58 | bool bDescend; //!< descend button presses. |
---|
59 | // bool bFire; //!< fire button pressed.(moved to playable) |
---|
60 | bool bRollL; //!< rolling button pressed (left) |
---|
61 | bool bRollR; //!< rolling button pressed (right) |
---|
62 | |
---|
63 | float xMouse; //!< mouse moved in x-Direction |
---|
64 | float yMouse; //!< mouse moved in y-Direction |
---|
65 | float mouseSensitivity; //!< the mouse sensitivity |
---|
66 | int yInvert; |
---|
67 | int controlVelocityX; |
---|
68 | int controlVelocityY; |
---|
69 | // float cycle; //!< hovercycle |
---|
70 | |
---|
71 | Vector velocity; //!< the velocity of the player. |
---|
72 | Vector oldVelocity; //!< the velocity the player had last synced |
---|
73 | Quaternion mouseDir; //!< the direction where the player wants to fly |
---|
74 | Quaternion oldMouseDir; //!< the direction where the player wanted to fly |
---|
75 | float shipInertia; //!< the inertia of the ship(how fast the ship reacts to a mouse input) |
---|
76 | Quaternion rotQuat; |
---|
77 | Quaternion pitchDir; |
---|
78 | float travelSpeed; //!< the current speed of the player (to make soft movement) |
---|
79 | float acceleration; //!< the acceleration of the player. |
---|
80 | |
---|
81 | float airViscosity; |
---|
82 | |
---|
83 | byte oldMask; //!< used for synchronisation |
---|
84 | |
---|
85 | ParticleEmitter* burstEmitter; |
---|
86 | ParticleSystem* burstSystem; |
---|
87 | }; |
---|
88 | |
---|
89 | #endif /* _SPACE_SHIPS_H */ |
---|