-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyboardModule.cpp
55 lines (48 loc) · 927 Bytes
/
KeyboardModule.cpp
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
/*
* KeyboardModule.cpp
*
* Created on: 11.04.2018
* Author: andr
*/
#include "KeyboardModule.h"
void KeyboardModule::init(HeroObject * hero, GLFWwindow* window)
{
Hero = hero;
Window = window;
isEscape = false;
isSpaceBar = false;
isLeft = false;
isRight = false;
}
void KeyboardModule::Tick()
{
isSpaceBar = false;
isLeft = false;
isRight = false;
if (glfwGetKey(Window, GLFW_KEY_SPACE))
{
if (isSpaceBar == false)
Hero->Jump();
isSpaceBar = true;
}
if (glfwGetKey(Window, GLFW_KEY_ESCAPE))
{
isEscape = true;
}
if (glfwGetKey(Window, GLFW_KEY_LEFT))
{
Hero->TurnAround(0.002f);
}
if (glfwGetKey(Window, GLFW_KEY_RIGHT))
{
Hero->TurnAround(-0.002f);
}
if (glfwGetKey(Window, GLFW_KEY_UP))
{
Hero->Forward(0.005f);
}
if (glfwGetKey(Window, GLFW_KEY_DOWN))
{
Hero->Forward(-0.005f);
}
}