added scr_lvled, a bunch of libraries, and improved framework code
[raydungeon] / src / game.h
1 #ifndef GAME_H_
2 #define GAME_H_
3
4 #define GAME_CFG_FILE   "game.cfg"
5
6 enum {
7         GKEY_ESC        = 27,
8         GKEY_DEL        = 127,
9         GKEY_F1         = 256,
10         GKEY_F2, GKEY_F3, GKEY_F4, GKEY_F5, GKEY_F6, GKEY_F7,
11         GKEY_F8, GKEY_F9, GKEY_F10, GKEY_F11, GKEY_F12,
12         GKEY_UP, GKEY_DOWN, GKEY_LEFT, GKEY_RIGHT,
13         GKEY_PGUP, GKEY_PGDOWN,
14         GKEY_HOME, GKEY_END,
15         GKEY_INS
16 };
17
18 enum {
19         GKEY_MOD_SHIFT  = 1,
20         GKEY_MOD_CTRL   = 4,
21         GKEY_MOD_ALT    = 8
22 };
23
24
25 struct game_screen {
26         const char *name;
27
28         int (*init)(void);
29         void (*destroy)(void);
30         int (*start)(void);
31         void (*stop)(void);
32         void (*display)(void);
33         void (*reshape)(int, int);
34         void (*keyboard)(int, int);
35         void (*mouse)(int, int, int, int);
36         void (*motion)(int, int);
37 };
38
39 extern int mouse_x, mouse_y, mouse_state[3];
40 extern int mouse_grabbed;
41 extern unsigned int modkeys;
42 extern int win_width, win_height;
43 extern float win_aspect;
44 extern int fullscr;
45
46 extern long time_msec;
47 extern struct game_screen *cur_scr;
48
49
50 int game_init(int argc, char **argv);
51 void game_shutdown(void);
52
53 void game_display(void);
54 void game_reshape(int x, int y);
55 void game_keyboard(int key, int press);
56 void game_mouse(int bn, int st, int x, int y);
57 void game_motion(int x, int y);
58
59 void game_chscr(struct game_screen *scr);
60
61 /* defined in main.c */
62 long game_getmsec(void);
63 void game_swap_buffers(void);
64 void game_quit(void);
65 void game_resize(int x, int y);
66 void game_fullscreen(int fs);
67 void game_grabmouse(int grab);
68 void game_vsync(int vsync);
69
70 #endif  /* GAME_H_ */