X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=01fcc1325d2ef10afb67369473362ba338fde4d3;hp=60ee8f099c696ac34fe5514527ee7bde1dd5300c;hb=ed58924474e942f5ae72645ecb73897979107f39;hpb=7981a2b8d152e6372aea8191f8c2197f866a450b diff --git a/main.c b/main.c index 60ee8f0..01fcc13 100644 --- a/main.c +++ b/main.c @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIN32 -# include -#endif #include #include #include @@ -44,6 +41,10 @@ #include "sprite.h" #include "sound.h" +#ifdef WIN32 +#define SetAlpha(surf, flag, alpha) +#endif + // ************************************* VARS // SDL_Surface global variables SDL_Surface @@ -529,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. @@ -590,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) { @@ -757,19 +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(); -#ifndef WIN32 - argp_parse(&argp, argc, argv, 0, 0, 0); -#endif + if(!parse_opts(argc, argv)) return 1; if(init()) { printf ("ta: '%s'\n",initerror);