-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyFunction.cpp
110 lines (105 loc) · 2.03 KB
/
keyFunction.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
#include "main.h"
void specialKeyDown(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_LEFT:
keystates[KEY::LEFT] = 1;
break;
case GLUT_KEY_RIGHT:
keystates[KEY::RIGHT] = 1;
break;
case GLUT_KEY_UP:
keystates[KEY::UP] = 1;
if (player.getState() == STAY) {
audio[0].PlayJump();
player.setState(JUMP);
player.setVelocityY(0.10f);
}
break;
case GLUT_KEY_DOWN:
keystates[KEY::DOWN] = 1;
break;
case GLUT_KEY_CTRL_L:
keystates[KEY::RESTART] = 1;
break;
}
}
void specialKeyUp(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_LEFT:
keystates[KEY::LEFT] = 0;
break;
case GLUT_KEY_RIGHT:
keystates[KEY::RIGHT] = 0;
break;
case GLUT_KEY_UP:
keystates[KEY::UP] = 0;
break;
case GLUT_KEY_DOWN:
keystates[KEY::DOWN] = 0;
break;
case GLUT_KEY_CTRL_L:
keystates[KEY::RESTART] = 0;
break;
}
}
void keyDown(unsigned char key, int x, int y)
{
if (win) {
if ('a' <= key && key <= 'z') {
input.addLetter(key);
}
if (key == BACKSPACE) {
input.deleteLastLetter();
}
if (key == ENTER) {
if (!board.isSaved()) {
board.addMyrecord(input.getName());
board.save();
board.setCounter(1);
}
}
}
switch (key) {
case spacebar:
keystates[KEY::SPACEBAR] = 1;
break;
case 'h':
if (gamestart == false) {
audio[4].PlayClick();
displayHelp = !displayHelp;
if (displayLeaderboard) displayLeaderboard = !displayLeaderboard;
}
break;
case 'H':
if (gamestart == false) {
audio[4].PlayClick();
displayHelp = !displayHelp;
if (displayLeaderboard) displayLeaderboard = !displayLeaderboard;
}
break;
case 'r':
if (gamestart == false) {
audio[4].PlayClick();
displayLeaderboard = !displayLeaderboard;
if (displayHelp) displayHelp = !displayHelp;
}
break;
case 'R':
if (gamestart == false) {
audio[4].PlayClick();
displayLeaderboard = !displayLeaderboard;
if (displayHelp) displayHelp = !displayHelp;
}
break;
}
}
void keyUp(unsigned char key, int x, int y)
{
switch (key) {
case spacebar:
keystates[KEY::SPACEBAR] = 0;
break;
}
}