]> git.itanic.dy.fi Git - sdl-planets/commitdiff
poll_events: Quit when requested to quit
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 30 Mar 2010 17:30:00 +0000 (20:30 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 30 Mar 2010 17:30:00 +0000 (20:30 +0300)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
main.c

diff --git a/main.c b/main.c
index ebdfa90e978da043657a0f3cd6bcd2cd190d1b84..11912512b7913e21de205f9cdf2eb90c017e1f32 100644 (file)
--- a/main.c
+++ b/main.c
@@ -52,8 +52,7 @@ static int poll_events(SDL_Surface **screen, struct camera *cam,
                case SDL_KEYDOWN:
                        switch (event.key.keysym.sym) {
                        case SDLK_ESCAPE:
-                               printf("\nExiting. Good bye!\n");
-                               return 1;
+                               goto quit;
                        case SDLK_LEFT:
                                cam->speed.x = -CAM_SPEED;
                                break;
@@ -122,10 +121,15 @@ static int poll_events(SDL_Surface **screen, struct camera *cam,
                                                   32,
                                                   screen[0]->flags);
                        break;
+               case SDL_QUIT:
+                       goto quit;
                }
        }
 
        return 0;
+quit:
+       printf("\nExiting. Good bye!\n");
+       return 1;
 }
 
 static void loop(SDL_Surface *screen, int num_of_planets, double total_mass,