]> git.itanic.dy.fi Git - sdl-planets/commitdiff
Merge branch 'master' into quadtree
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 8 Apr 2010 16:34:41 +0000 (19:34 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 8 Apr 2010 16:34:41 +0000 (19:34 +0300)
.gitignore
Makefile
main.c

index 263fdabceaeffad8e84ed88ca87e22d62cfc2635..b188e79e5b85b6c7dbc7c14c71a758c405eecb82 100644 (file)
@@ -3,3 +3,4 @@
 .*.d
 TAGS
 sdl-planet
+debug-planet
index c4c765204c9c14460cdef19c5e2735f4923f533d..5b89e4f375832a789449d6fb6518bb17a34d08fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ PLANET_DEBUG_OBJS= $(patsubst %.o,%-debug.o,$(PLANET_OBJS))
 sdl-planet: $(PLANET_OBJS)
        gcc $(LIBS) -o $@ $(PLANET_OBJS)
 
-debug-planets: $(PLANET_DEBUG_OBJS)
+debug-planet: $(PLANET_DEBUG_OBJS)
        gcc $(LIBS) -o $@ $(PLANET_DEBUG_OBJS) -DDEBUG
 
 .c.o:
@@ -36,7 +36,8 @@ TAGS:
        @etags *.[ch]
 
 clean:
-       rm -rfv $(PLANET_OBJS) $(PLANET_DEBUG_OBJS) *~ sdl-planet TAGS .*.d
+       rm -rfv $(PLANET_OBJS) $(PLANET_DEBUG_OBJS) *~ sdl-planet TAGS .*.d \
+               debug-planet
 
 .PHONY: all clean TAGS
 
diff --git a/main.c b/main.c
index 2241d42b6e1f52ee4a3ec849e4e6f8b47b4a5448..c383af71e05f7fe7ad52c059000d0c4a3cd20e62 100644 (file)
--- a/main.c
+++ b/main.c
@@ -191,7 +191,7 @@ static void loop(SDL_Surface *screen, int num_of_planets, double total_mass,
        int last_framecount = 0, last_step_count = 0;
        unsigned long old_ticks, ticks = 0, last_frame_tick = 0;
        unsigned long step_count = 0;
-       double last_fps = 0, last_sps = 0;
+       double last_fps = 0, last_sps = 0, fade_amount;
        double step_time = 0, true_time = 0;
 
        init_camera(&camera);
@@ -244,14 +244,14 @@ static void loop(SDL_Surface *screen, int num_of_planets, double total_mass,
                if (last_frame_tick + (1000 * 1000) / MAX_FPS > ticks)
                        continue;
 
-               last_frame_tick = ticks;
-
                SDL_LockSurface(screen);
 
                if (status.tracers_enabled &&
                    !camera.speed.x && !camera.speed.y &&
                    camera.zoom_rate == 1) {
-                       fade_buf(screen, 10 * true_time);
+                       fade_amount = (ticks - last_frame_tick) /
+                               (1000 * 1000.0) * 20;
+                       fade_buf(screen, fade_amount);
                } else {
                        clear_buf(screen);
                }
@@ -265,6 +265,8 @@ static void loop(SDL_Surface *screen, int num_of_planets, double total_mass,
 
                SDL_Flip(screen);
 
+               last_frame_tick = ticks;
+
                if (last_fps_time + (500 * 1000) < ticks) {
                        last_framecount = framecount - last_framecount;
                        last_fps = last_framecount * 1000 * 1000 /