logo
[eradicate] / src / menuscr.c
1 #include <stdio.h>
2 #include "screens.h"
3 #include "imago2.h"
4 #include "gfx.h"
5 #include "gfxutil.h"
6 #include "game.h"
7
8 static void *bgpix;
9 static int bgwidth, bgheight;
10
11 int menu_init(void)
12 {
13         if(!(bgpix = img_load_pixels("data/menbg640.png", &bgwidth, &bgheight, IMG_FMT_RGB24))) {
14                 fprintf(stderr, "failed to load menu bg image\n");
15                 return -1;
16         }
17         convimg_rgb24_rgb16(bgpix, bgpix, bgwidth, bgheight);
18         return 0;
19 }
20
21 void menu_cleanup(void)
22 {
23         img_free_pixels(bgpix);
24 }
25
26 void menu_start(void)
27 {
28         draw = menu_draw;
29         key_event = menu_keyb;
30 }
31
32 void menu_stop(void)
33 {
34 }
35
36 void menu_draw(void)
37 {
38         blit_frame(bgpix, 1);
39 }
40
41 void menu_keyb(int key, int pressed)
42 {
43         switch(key) {
44         case 27:
45                 game_quit();
46                 break;
47         }
48 }