From: Joshua Grams Date: Fri, 24 Mar 2006 20:39:11 +0000 (+0000) Subject: oops, pressing space was skipping high score entry. X-Git-Tag: 0.4~15 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=5b6e786d0bc01f9f278f75afebcbc0947556fbce oops, pressing space was skipping high score entry. --- diff --git a/main.c b/main.c index 63c8c4a..fdf96fb 100644 --- a/main.c +++ b/main.c @@ -532,6 +532,17 @@ do_collision(Sprite *a, Sprite *b) } void +init_score_entry(void) +{ + SDL_Event e; + state = HIGH_SCORE_ENTRY; + state_timeout = 5.0e6; + SDL_EnableUNICODE(1); + while(SDL_PollEvent(&e)) + ; +} + +void gameloop() { Uint8 *keystate = SDL_GetKeyState(NULL); float tmp; @@ -553,14 +564,8 @@ gameloop() { play_tune(TUNE_GAMEPLAY); break; case GAME_OVER: - if(new_high_score(score)) { - SDL_Event e; - state = HIGH_SCORE_ENTRY; - state_timeout = 5.0e6; - SDL_EnableUNICODE(1); - while(SDL_PollEvent(&e)) - ; - } else { + if(new_high_score(score)) init_score_entry(); + else { state = HIGH_SCORE_DISPLAY; state_timeout = 400; } @@ -655,21 +660,25 @@ gameloop() { && (state == HIGH_SCORE_DISPLAY || state == TITLE_PAGE || state == GAME_OVER)) { - reset_sprites(); - reset_rocks(); - screendx = SCREENDXMIN; screendy = 0; - - ship.x = XSIZE/2.2; ship.y = YSIZE/2; - ship.dx = screendx; ship.dy = screendy; - ship.lives = 4; - ship.flags = MOVE|DRAW|COLLIDE; - SDL_SetAlpha(ship.image, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - add_sprite(SPRITE(&ship)); - - score = 0; - - state = GAMEPLAY; - play_tune(TUNE_GAMEPLAY); + if(state == GAME_OVER && new_high_score(score)) + init_score_entry(); + else { + reset_sprites(); + reset_rocks(); + screendx = SCREENDXMIN; screendy = 0; + + ship.x = XSIZE/2.2; ship.y = YSIZE/2; + ship.dx = screendx; ship.dy = screendy; + ship.lives = 4; + ship.flags = MOVE|DRAW|COLLIDE; + SDL_SetAlpha(ship.image, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + add_sprite(SPRITE(&ship)); + + score = 0; + + state = GAMEPLAY; + play_tune(TUNE_GAMEPLAY); + } } ship.jets = 0;