X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=288d8336609045d6350755c222782b094a0ac4f9;hp=11ebba6e600562f02b6ce0e66a99106ca0ffde88;hb=288c9419914dd80e03e7c172c0c7b4f1f6605948;hpb=31a00c721be0b569bc554069cc0a3eb2864eb61f diff --git a/main.c b/main.c index 11ebba6..288d833 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include #include @@ -42,6 +41,10 @@ #include "sprite.h" #include "sound.h" +#ifdef WIN32 +#define SDL_SetAlpha(surf, flag, alpha) +#endif + // ************************************* VARS // SDL_Surface global variables SDL_Surface @@ -391,12 +394,12 @@ init(void) { } // Load the banners - NULLERROR(surf_b_variations = load_image("variations.png")); - NULLERROR(surf_b_on = load_image("on.png")); - NULLERROR(surf_b_rockdodger = load_image("rockdodger.png")); + NULLERROR(surf_b_variations = load_image("b_variations.png")); + NULLERROR(surf_b_on = load_image("b_on.png")); + NULLERROR(surf_b_rockdodger = load_image("b_rockdodger.png")); - NULLERROR(surf_b_game = load_image("game.png")); - NULLERROR(surf_b_over = load_image("over.png")); + NULLERROR(surf_b_game = load_image("b_game.png")); + NULLERROR(surf_b_over = load_image("b_over.png")); // Load the life indicator (small ship) graphic. NULLERROR(surf_life = load_image("life.png")); @@ -527,17 +530,6 @@ draw(void) { case HIGH_SCORE_ENTRY: play_tune(TUNE_HIGH_SCORE_ENTRY); - if(!process_score_input()) { // done inputting name - - // Change state to briefly show high scores page - state = HIGH_SCORE_DISPLAY; - state_timeout = 200; - - // Write the high score table to the file - write_high_score_table(); - - play_tune(TUNE_TITLE_PAGE); - } // FALL THROUGH TO case HIGH_SCORE_DISPLAY: // Display de list o high scores mon. @@ -588,12 +580,33 @@ init_score_entry(void) void gameloop() { - Uint8 *keystate = SDL_GetKeyState(NULL); + SDL_Event e; + Uint8 *keystate; float tmp; for(;;) { - SDL_PumpEvents(); + while(SDL_PollEvent(&e)) { + switch(e.type) { + case SDL_QUIT: return; + case SDL_KEYUP: + if(e.key.keysym.sym == SDLK_ESCAPE + || e.key.keysym.sym == SDLK_q) + return; + break; + case SDL_KEYDOWN: + if(state == HIGH_SCORE_ENTRY) + if(!process_score_input(&e.key.keysym)) { + // Write the high score table to the file + write_high_score_table(); + // continue to display the scores briefly + state = HIGH_SCORE_DISPLAY; + state_timeout = 200; + play_tune(TUNE_TITLE_PAGE); + } + break; + } + } keystate = SDL_GetKeyState(NULL); if(!paused) { @@ -755,17 +768,12 @@ gameloop() { state = HIGH_SCORE_DISPLAY; state_timeout = 400; } - - if(state != HIGH_SCORE_ENTRY && (keystate[SDLK_q] || keystate[SDLK_ESCAPE])) - return; - } } int main(int argc, char **argv) { - init_opts(); - argp_parse(&argp, argc, argv, 0, 0, 0); + if(!parse_opts(argc, argv)) return 1; if(init()) { printf ("ta: '%s'\n",initerror);