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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <unistd.h>
#include "main.h"
extern SDL_Surface *screen;
extern int keyboard[];
void hsc_save();
GAMESTATE state;
GAMESTATE laststate;
int score;
int lives;
int volume=2; /* 0-3 */
int difficulty=DIFF_EASY;
int main(int argc, char *argv[])
{
chdir(DATA);
game_init(argc, argv);
while (state.mainstate!=ST_GAME_QUIT) {
keyboard_poll();
switch(state.mainstate) {
case ST_START_INTRO:
if(state.newstate) {
startintro_init();
state.newstate=0;
}
startintro_work();
break;
case ST_INTRO:
if(state.newstate) {
intro_init();
state.newstate=0;
}
intro_work();
break;
case ST_GAME_PLAY:
if(state.newstate) {
thegame_init();
state.newstate=0;
}
thegame_work();
break;
case ST_GAME_OVER:
if(state.newstate) {
gameover_init();
state.newstate=0;
}
gameover_work();
break;
case ST_MENU:
if(state.newstate) {
menu_init();
state.newstate=0;
}
menu_work();
break;
case ST_SHOW_HCLIST:
if(state.newstate) {
hsc_show_init();
state.newstate=0;
}
hsc_show_work();
break;
case ST_ENTRY_HCLIST:
if(state.newstate) {
hsc_entry_init();
state.newstate=0;
}
hsc_entry_work();
break;
}
fps_show();
SDL_Flip(screen);
fps_newframe();
}
hsc_save(); // save hiscore
/* TODO: Free everything (memory, SDL_Surfaces, Joysticks...) */
fprintf(stdout,"Thank you for playing\n");
exit(0);
}
|