1 /* 2 XorGramana Copyright 2009 James W. Morris, james@jwm-art.net 3 4 This file is part of XorGramana. 5 6 XorGramana is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 XorGramana is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with XorGramana. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include <stdlib.h> 21 22 #include "gfx.h" 23 24 #include "level_menu.h" 25 26 #include "movelist.h" 27 28 #include "play_xor.h" 29 #include "options.h" 30 #include "scores.h" 31 #include "input.h" 32 #include "mapdisplay.h" 33 #include "actions.h" 34 35 void splash(); 36 main(void)37int main(void) 38 { 39 lvl_t lastlevel; 40 lvl_t level=1; 41 if(!options_create()){ 42 printf("Please either install XorGramana by running 'sudo make install' within the\n"); 43 printf("XorGramana source directory, or always start XorGramana from within that\n"); 44 printf("directory.\n"); 45 exit(1); 46 } 47 create_scores(); 48 load_scores(); 49 gfx_start(); 50 init_icons(); 51 icons_init_overlays(); 52 game_win_create(); 53 level_win_create(); 54 play_create_keys(); 55 map_display_create_keys(); 56 key_repeat_on(); 57 scr_win_border(); 58 do{ 59 lastlevel=level; 60 level=level_menu(level); 61 switch(level){ 62 case 100: 63 if((level=replay_load())<0) 64 level=lastlevel; 65 else if(level==100){ 66 while(play_xor(level,FALSE)); 67 level=replay.level; 68 level=replay.level; 69 scr_win_border(); 70 } 71 break; 72 case 999: 73 level=lastlevel; 74 help(); 75 break; 76 default: 77 if(level>=MIN_LEVEL&&level<=MAX_LEVEL){ 78 if(play_xor(level,TRUE)){ 79 while(play_xor(level,FALSE)){ 80 scr_win_border(); 81 } 82 level=replay.level; 83 } 84 scr_win_border(); 85 } 86 } 87 }while(level>=0&&!xginput.exit); 88 map_display_destroy_keys(); 89 map_display_destroy_icons(); 90 play_destroy_keys(); 91 game_win_destroy(); 92 level_win_destroy(); 93 icons_cleanup(); 94 gfx_end(); 95 destroy_scores(); 96 options_destroy_map_names(); 97 options_destroy(); 98 return 0; 99 } 100 101