main menu screen causing game to crash
cameron

sorry about posting 2 help threads soo quickly, just having some trouble learning the ropes. here is my main screen code. when i compile and run, i get a not responding error and the program is forced to close. i never get to see anything but a black screen.

1#include <allegro.h>
2 
3int selected = 1;
4 
5int main()
6{
7 allegro_init();
8 install_keyboard();
9
10 set_color_depth(16);
11 set_gfx_mode(GFX_AUTODETECT, 640,480,0,0);
12
13 // screen images
14 BITMAP *screen_play = load_bitmap("img/screen_play.gif", NULL);
15 BITMAP *screen_help = load_bitmap("img/screen_help.gif", NULL);
16 BITMAP *screen_exit = load_bitmap("img/screen_exit.gif", NULL);
17
18 while ( !key[KEY_ESC] ){
19
20 if (key[KEY_UP]) selected --;
21 else if (key[KEY_DOWN]) selected ++;
22
23 if (selected == 4) selected = 1;
24 else if (selected == 0) selected = 3;
25
26 acquire_screen();
27
28 if (selected == 1) blit(screen_play, screen, 0,0,0,0,640,480);
29 else if (selected == 2) blit(screen_help, screen, 0,0,0,0,640,480);
30 else if (selected == 3) blit(screen_exit, screen, 0,0,0,0,640,480);
31
32 release_screen();
33
34 }
35 
36 destroy_bitmap(screen_play);
37 destroy_bitmap(screen_help);
38 destroy_bitmap(screen_exit);
39
40 return 0;
41}
42END_OF_MAIN()

the cuase probably seems obvious to you guys, but i'm stumped. by the way, all the images are in their correct places.

gnolam

Check your return values. All of them. As it is, you have no idea if your graphics mode is being set properly or if the bitmaps are being loaded or anything. Add error checking to your program, test it, and then come back to us.

Thread #589553. Printed from Allegro.cc