-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathon_key.c
52 lines (45 loc) · 994 Bytes
/
on_key.c
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
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <math.h>
#include "on_key.h"
#include "constante.h"
#include "on_timer.h"
void on_keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27: //escape
exit(EXIT_SUCCESS);
break;
case 'g'://go
case 'G':
if(!animation_ongoing){
animation_ongoing=1;
glutTimerFunc(TIMER_INTERVAL, on_timer, TIMER_ID);
}
break;
case 'p'://pause
case 'P':
animation_ongoing=0;
break;
case 'a'://left
case 'A':
if (stanje ==0){
signal=-1;break;
}else if(stanje==2){
signal=-10;break;
}else if(stanje ==-2){
break;
}
case 'd'://right
case 'D':
if (stanje ==0){
signal=1;break;
}else if(stanje==-2){
signal=10;break;
}else if(stanje ==2){
break;
}
}
}