diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_fps_count.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ft_get_fps_count.c b/src/ft_get_fps_count.c index 16306c1..74afb45 100644 --- a/src/ft_get_fps_count.c +++ b/src/ft_get_fps_count.c @@ -22,7 +22,19 @@ static float return ((ticks / (float)CLOCKS_PER_SEC) * 1000.0); } -#include <stdio.h> + +static void + ft_handle_firing(clock_t dt, t_cub *cl) +{ + static clock_t curr_time = 0; + + curr_time += dt; + if (dt > 0 && ft_clock_to_ms(curr_time) > 200.0) + { + cl->plist.fire = 0; + curr_time -= CLOCKS_PER_SEC; + } +} void ft_get_fps_count(clock_t dt, t_cub *cl) @@ -30,6 +42,8 @@ void static clock_t curr_time = 0; curr_time += dt; + if (cl->plist.fire == 1) + ft_handle_firing(dt, cl); if (dt > 0 && ft_clock_to_ms(curr_time) > 1000.0) { ft_sprintf(cl->fps_count, "fps: %ld", (uint32_t)CLOCKS_PER_SEC / dt); |