-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyHandler.h
140 lines (117 loc) · 3.3 KB
/
KeyHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Key handler.
// -------------------------------------------------------------------
// Copyright (C) 2007 OpenEngine.dk (See AUTHORS)
//
// This program is free software; It is covered by the GNU General
// Public License version 2 or any later version.
// See the GNU General Public License for more details (see LICENSE).
//--------------------------------------------------------------------
#ifndef _KEY_HANDLER_H_
#define _KEY_HANDLER_H_
#include "TimeModifier.h"
// inherits from
#include <Core/IListener.h>
#include <Core/EngineEvents.h>
#include <Display/FollowCamera.h>
/*
#include <Devices/IMouse.h>
#include <Scene/TransformationNode.h>
*/
#include <Devices/IKeyboard.h>
#include <Devices/IJoystick.h>
#include <list>
#include "Modules/Island/HeightMap.h"
#include "GameState.h"
class BoidsSystem;
class Dragon;
class InputGrabber;
class Intro;
class Island;
class Target;
namespace OpenEngine {
namespace Devices {
class IKeyboard;
class IMouse;
}
namespace Display {
class Camera;
}
namespace Scene {
class TransformationNode;
}
namespace Sound {
class MusicPlayer;
}
}
using namespace OpenEngine::Core;
using namespace OpenEngine::Display;
using namespace OpenEngine::Scene;
using namespace OpenEngine::Devices;
using namespace OpenEngine::Sound;
using std::list;
class KeyHandler : public IListener<ProcessEventArg>,
public IListener<KeyboardEventArg>,
public IListener<JoystickButtonEventArg>,
public IListener<JoystickAxisEventArg> {
private:
Intro* intro;
Island* island;
Dragon* dragon;
BoidsSystem* boidssystem;
FollowCamera& camera;
TransformationNode& target;
HeightMap& hmap;
IMouse& mouse;
TimeModifier& timeModifier;
GameState& gamestate;
IFrame& frame;
RenderStateNode *rn;
bool done, pause;
list<Key> keysPressed;
float timeFactor;
float gainStep;
float moveChunkMouse, rotChunkMouse, moveChunkKeyboard, rotChunkKeyboard;
int mousex_prev, mousey_prev, mousex_orig, mousey_orig;
bool warping;
float up,down,left,right;
float cam_up,cam_down,cam_left,cam_right;
MusicPlayer& musicplayer;
void CheckCameraCollision();
public:
KeyHandler(FollowCamera& camera,
TransformationNode& target,
HeightMap& hmap,
IMouse& mouse,
Island* island,
Dragon* dragon,
BoidsSystem* boidssystem,
TimeModifier& timeModifer,
GameState& gamestate,
#ifdef DRAGON_SOUND
MusicPlayer& musicplayer,
#endif
IFrame& frame,
RenderStateNode* rn);
~KeyHandler();
void Handle(KeyboardEventArg arg);
void HandleUp(Key key);
void HandleDown(Key key);
void Handle(ProcessEventArg arg);
void Handle(JoystickAxisEventArg arg);
void Handle(JoystickButtonEventArg arg);
void ResetTarget();
void ResetCamera();
void ResetGame();
void TogglePauseGame();
void MoveForward(float d);
void MoveBack(float d);
void MoveRight(float d);
void MoveLeft(float d);
void RotateUp(float d);
void RotateDown(float d);
void RotateRight(float d);
void RotateLeft(float d);
void ZoomIn(float d);
void ZoomOut(float d);
};
#endif // _KEY_HANDLER_H_