1 | |
---|
2 | /*! |
---|
3 | * @file helicopter.h |
---|
4 | * Implements the Control of a Helicopter |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _HELICOPTER_H |
---|
8 | #define _HELICOPTER_H |
---|
9 | |
---|
10 | #include "playable.h" |
---|
11 | |
---|
12 | #include "sound_buffer.h" |
---|
13 | #include "sound_source.h" |
---|
14 | |
---|
15 | #include "script_class.h" |
---|
16 | |
---|
17 | class Helicopter : public Playable |
---|
18 | { |
---|
19 | |
---|
20 | public: |
---|
21 | |
---|
22 | Helicopter(); |
---|
23 | Helicopter(const std::string& fileName); |
---|
24 | Helicopter(const TiXmlElement* root); |
---|
25 | virtual ~Helicopter(); |
---|
26 | |
---|
27 | virtual void loadParams(const TiXmlElement* root); |
---|
28 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) {/* FIXME */}; |
---|
29 | |
---|
30 | virtual void enter(); |
---|
31 | virtual void leave(); |
---|
32 | |
---|
33 | virtual void postSpawn(); |
---|
34 | virtual void leftWorld(); |
---|
35 | |
---|
36 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
37 | virtual void tick(float time); |
---|
38 | virtual void draw() const; |
---|
39 | |
---|
40 | virtual void process(const Event &event); |
---|
41 | |
---|
42 | virtual void moveUp(bool move){bAscend = move;}; |
---|
43 | virtual void moveDown(bool move){bDescend = move;}; |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | private: |
---|
48 | void init(); |
---|
49 | void calculateVelocity(float time); |
---|
50 | |
---|
51 | bool bUp; //!< up button pressed. |
---|
52 | bool bDown; //!< down button pressed. |
---|
53 | bool bLeft; //!< left button pressed. |
---|
54 | bool bRight; //!< right button pressed. |
---|
55 | bool bAscend; //!< ascend button pressed. |
---|
56 | bool bDescend; //!< descend button presses. |
---|
57 | bool bFire; //!< fire button pressed. |
---|
58 | bool bRollL; //!< rolling button pressed (left) |
---|
59 | bool bRollR; //!< rolling button pressed (right) |
---|
60 | |
---|
61 | float xMouse; //!< mouse moved in x-Direction |
---|
62 | float yMouse; //!< mouse moved in y-Direction |
---|
63 | int yInvert; |
---|
64 | float mouseSensitivity; //!< the mouse sensitivity |
---|
65 | int controlVelocityX; //!< defines max velocity of Xaxis of mousecontrol |
---|
66 | int controlVelocityY; //!< defines max velocity of Yaxis of mousecontrol |
---|
67 | |
---|
68 | PNode topRotor; //!< the position of the toprotor |
---|
69 | PNode tailRotor; //!< the position of the tailrotor |
---|
70 | |
---|
71 | PNode cameraNode; //!< the position the camera is locked at (used to look up and down without turning the helicopter) |
---|
72 | |
---|
73 | Vector velocity; //!< the velocity of the player. |
---|
74 | Vector velocityDir; //!< the direction of the velocity of the spaceship |
---|
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 | OrxSound::SoundSource soundSource; |
---|
81 | OrxSound::SoundBuffer*chopperBuffer; |
---|
82 | |
---|
83 | }; |
---|
84 | |
---|
85 | CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER, |
---|
86 | addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp)) |
---|
87 | ->addMethod("moveDown", ExecutorLua1<Helicopter,bool>(&Helicopter::moveDown)) |
---|
88 | ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) |
---|
89 | ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) |
---|
90 | ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) |
---|
91 | ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) |
---|
92 | |
---|
93 | ); |
---|
94 | |
---|
95 | |
---|
96 | #endif /* _HELICOPTERS_H */ |
---|