From 5b6e786d0bc01f9f278f75afebcbc0947556fbce Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Fri, 24 Mar 2006 20:39:11 +0000 Subject: [PATCH] oops, pressing space was skipping high score entry. --- main.c | 55 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) 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; -- 1.7.10.4