-
Notifications
You must be signed in to change notification settings - Fork 1
/
arrows.cpp
34 lines (31 loc) · 899 Bytes
/
arrows.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
int event;
if ((event = gfx_event_waiting()) == 1){
c = gfx_wait();
changedirection(c, holdLoop, snake);
}
void changedirection(char c, bool &loop, Snake &snake){
switch(c){
case 'R': // up arrow
snake.up();
break;
case 'Q': // left arrow
snake.left();
break;
case 'T': // down arrow
snake.down();
break;
case 'S': // right arrow
snake.right();
break;
case 'q': // quit the game
loop = false;
break;
case 'p': // pause the game
c = gfx_wait();
while ( c != 'p'){
c = gfx_wait();
}
break;
default:
return;
}