-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.hpp
executable file
·52 lines (46 loc) · 1.56 KB
/
Input.hpp
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
//
// Input.hpp
// CS155 Project
//
// Created by Gus Callaway on 12/7/17.
// Copyright © 2017 Gus Callaway. All rights reserved.
//
#ifndef Input_hpp
#define Input_hpp
#include "Camera.hpp"
class Input {
public:
Input(Camera* camera);
void ProcessKey(const char key, bool isPress);
void ProcessMouse(int x, int y);
// This function should be called every frame to
// allow held keys to function properly.
void Update();
// Input shifts are just values in [0,1] that are
// affected by pressing an up or down key. They can
// be used to affect how the tunnel looks based on
// user input.
static const int numShifts = 5;
float inputShifts[numShifts] = {0, 0.25, 0.5, 0, 0};
// Rotation is different because it isn't bound to
// [0, 1]. It controls what direction the tunnel
// curves in.
float rotation = 0;
// This value is used for a simple key press trigger.
// For that, we want to know how long ago the user
// pressed the key. To allow for multiple presses
// to be registered, we need an array. A value of
// -1 in the array represents an open slot.
static const int maxPresses = 100;
float framesSincePress[maxPresses];
bool paused = true;
private:
Camera* camera;
// 2 keys per shift plus 2 for rotation
bool keysDown[numShifts*2 + 2];
// Input sensitivities control how fast input shifts
// change from frame to frame
float inputSensitivities[numShifts] = {.0048, .003, .0048, .0048, .0048};
float rotationSensitivity = .0048;
};
#endif /* Input_hpp */