-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathevents.cpp
More file actions
67 lines (63 loc) · 1.83 KB
/
events.cpp
File metadata and controls
67 lines (63 loc) · 1.83 KB
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
/* events.cpp
* Omkar H. Ramachandran
*
* SDL definitions for processing events
*
*/
#include "general.h"
void key_press(SDL_keysym* keysym, Camera *C, int * fps){
switch(keysym->sym){
case SDLK_ESCAPE:
quit(0);
break;
case SDLK_SPACE:
fprintf(stderr,"FPS = %d\n",*fps);
break;
case SDLK_UP:
case SDLK_KP8:
C->Move(-1);
is_change = true;
break;
case SDLK_DOWN:
case SDLK_KP2:
C->Move(+1);
is_change = true;
break;
case SDLK_KP4:
case SDLK_LEFT:
C->Move(-2);
is_change = true;
break;
case SDLK_KP6:
case SDLK_RIGHT:
C->Move(2);
is_change = true;
break;
case SDLK_p:
C->print();
break;
case SDLK_w:
C->Zoom(-0.05f);
break;
case SDLK_x:
C->Zoom(0.05f);
break;
case SDLK_m:
mode = (mode==1)?0:1;
default:
break;
}
}
void process_events(Camera *C,int *fps){
SDL_Event event;
while(SDL_PollEvent(&event)){
switch(event.type){
case SDL_KEYDOWN:
key_press(&event.key.keysym,C,fps);
break;
case SDL_QUIT:
quit(0);
break;
}
}
}