-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyHandler.h
More file actions
159 lines (135 loc) · 3.92 KB
/
KeyHandler.h
File metadata and controls
159 lines (135 loc) · 3.92 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// 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 OscSurface;
class Target;
class DragonHUD;
namespace OpenEngine {
namespace Devices {
class IKeyboard;
class IMouse;
}
namespace Display {
class Camera;
class IFrame;
}
namespace Scene {
class TransformationNode;
}
namespace Sound {
class MusicPlayer;
}
namespace Utils {
class MoveHandler;
}
}
using namespace OpenEngine::Core;
using namespace OpenEngine::Display;
using namespace OpenEngine::Scene;
using namespace OpenEngine::Devices;
using namespace OpenEngine::Sound;
using namespace OpenEngine::Utils;
using std::list;
class KeyHandler : public IListener<OpenEngine::Core::InitializeEventArg>,
public IListener<OpenEngine::Core::ProcessEventArg>,
public IListener<KeyboardEventArg>,
public IListener<JoystickButtonEventArg>,
public IListener<JoystickAxisEventArg> {
private:
Intro* intro;
Island* island;
Dragon* dragon;
BoidsSystem* boidssystem;
FollowCamera& camera;
TransformationNode& targetTNode;
Target& targetBox;
HeightMap& hmap;
IMouse& mouse;
TimeModifier& timeModifier;
GameState& gamestate;
OscSurface& oscs;
DragonHUD& hud;
IRenderCanvas& canvas;
IFrame& frame;
RenderStateNode *rn;
Camera* freeCamera;
MoveHandler* freeCamHandler;
bool useGameCamera;
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_in,cam_out,cam_up,cam_down,cam_left,cam_right;
MusicPlayer& musicplayer;
void CheckCameraCollision();
public:
KeyHandler(FollowCamera& camera,
TransformationNode& targetTNode,
Target& targetBox,
HeightMap& hmap,
IMouse& mouse,
Island* island,
Dragon* dragon,
BoidsSystem* boidssystem,
TimeModifier& timeModifer,
GameState& gamestate,
MusicPlayer& musicplayer,
OscSurface& oscs,
DragonHUD& hud,
IRenderCanvas& canvas,
IFrame& frame,
RenderStateNode* rn);
~KeyHandler();
void Handle(KeyboardEventArg arg);
void HandleUp(KeyboardEventArg arg);
void HandleDown(KeyboardEventArg arg);
void Handle(OpenEngine::Core::InitializeEventArg arg);
void Handle(OpenEngine::Core::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_