-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameController.cpp
124 lines (117 loc) · 3.21 KB
/
gameController.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
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
#include "headers.hpp"
#include "varStore.hpp"
gameController::gameController(){
this->go.initTiles();
this->go.initBlock();
}
void gameController::displayAll(){
if(isHelicopterView){
vp->zoomInHelicopter();
if(isRotating){
vp->setHelicopterView();
}
}
this->go.displayTiles();
this->go.displayBlock();
// if Winner, then display winning screen
}
void gameController::key_callback(GLFWwindow* window, int key, int scancode, int action, int mode){
//newTime = glfwGetTime();
//if(newTime - oldTime >= 0.5f){
//oldTime = newTime;
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS){
wc->close();
}
else if(key == GLFW_KEY_RIGHT && action == GLFW_PRESS && Angle<=0.0f){
Angle = acos(0.0f);
gc->go.rotation(1, 0, 0, 0.1f);
}
else if(key == GLFW_KEY_LEFT && action == GLFW_PRESS && Angle<=0.0f){
Angle = acos(0.0f);
gc->go.rotation(-1, 0, 0, 0.1f);
}
else if(key == GLFW_KEY_UP && action == GLFW_PRESS && Angle<=0.0f){
Angle = acos(0.0f);
gc->go.rotation(0, 0, 1, 0.1f);
}
else if(key == GLFW_KEY_DOWN && action == GLFW_PRESS && Angle<=0.0f){
Angle = acos(0.0f);
gc->go.rotation(0, 0, -1, 0.1f);
}
else if(key == GLFW_KEY_T && action == GLFW_PRESS){
isBlockView = false;
isFollowView = false;
isHelicopterView = false;
vp->setTopView();
}
else if(key == GLFW_KEY_O && action == GLFW_PRESS){
isBlockView = false;
isFollowView = false;
isHelicopterView = false;
vp->setTowerView();
}
else if(key == GLFW_KEY_B && action == GLFW_PRESS){
isBlockView = true;
isFollowView = false;
isHelicopterView = false;
vp->setBlockView();
}
else if(key == GLFW_KEY_N && action == GLFW_PRESS){
isBlockView = false;
isFollowView = false;
isHelicopterView = false;
vp->setNormalView();
}
else if(key == GLFW_KEY_F && action == GLFW_PRESS){
isFollowView = true;
isBlockView = false;
isHelicopterView = false;
vp->setFollowView();
}
else if(key == GLFW_KEY_H && action == GLFW_PRESS){
isFollowView = false;
isBlockView = false;
isHelicopterView = true;
vp->setHelicopterView();
}
/*
else if(key == GLFW_KEY_A && action == GLFW_PRESS && isHelicopterView){
vp->rotateHelicopterCW();
vp->setHelicopterView();
}
else if(key == GLFW_KEY_D && action == GLFW_PRESS && isHelicopterView){
vp->rotateHelicopterACW();
vp->setHelicopterView();
}
else if(key == GLFW_KEY_W && action == GLFW_PRESS && isHelicopterView){
vp->zoomInHelicopter();
vp->setHelicopterView();
}
else if(key == GLFW_KEY_S && action == GLFW_PRESS && isHelicopterView){
vp->zoomOutHelicopter();
vp->setHelicopterView();
}*/
//}
}
void gameController::mouse_moveCallback(GLFWwindow* window, double xpos, double ypos){
}
void gameController::mouse_buttonCallback(GLFWwindow* window, int button, int action, int mods){
switch(button) {
case GLFW_MOUSE_BUTTON_RIGHT:
if(isHelicopterView){
if(action == GLFW_PRESS){
glfwGetCursorPos(window, &xCursor, &yCursor);
isRotating = true;
}
if(action == GLFW_RELEASE){
isRotating = false;
}
}
break;
default:
break;
}
}
void gameController::mouse_scrollCallback(GLFWwindow* window, double xoffset, double yoffset){
zoomFactor = zoomFactor + yoffset;
}