]> git.itanic.dy.fi Git - sdl-planets/commitdiff
main.c: Clear the window instead of fading it
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 6 Mar 2010 18:41:06 +0000 (20:41 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 6 Mar 2010 18:41:06 +0000 (20:41 +0200)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
main.c

diff --git a/main.c b/main.c
index 3d7863e24d636db70380d8e5e6faedda193e9406..09fc059e9deffc6c7689356dc0082d498cfbeee8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -17,6 +17,15 @@ static void fade_buf(SDL_Surface *screen, double amount)
                buf[i] = (buf[i] < amount) ? 0 : buf[i] - amount;
 }
 
+static void clear_buf(SDL_Surface *screen)
+{
+       int i;
+       unsigned int *buf = screen->pixels;
+
+       for(i = 0; i < screen->pitch * screen->h / 4; i++)
+               buf[i] = 0;
+}
+
 static void loop(SDL_Surface *screen)
 {
        int num_of_planets = 100;
@@ -41,12 +50,11 @@ static void loop(SDL_Surface *screen)
 
                SDL_LockSurface(screen);
 
+               clear_buf(screen);
+
                for (i = 0; i < num_of_planets; i++)
                        draw_planet(screen, &planet[i]);
 
-               if (!(framecount % 64))
-                       fade_buf(screen, 1);
-
                SDL_UnlockSurface(screen);
 
                SDL_Flip(screen);