diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-24 14:25:19 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-24 14:25:19 +0100 |
commit | 4f154eaf3a8f531999db140c2040f10016042b9d (patch) | |
tree | 7933ef9c6cdf5363ea6b08ff16e9a07ee5253490 /src/ft_get_fps_count.c | |
parent | Doesn't look too bad (diff) | |
download | 42-cub3d-4f154eaf3a8f531999db140c2040f10016042b9d.tar.gz 42-cub3d-4f154eaf3a8f531999db140c2040f10016042b9d.tar.bz2 42-cub3d-4f154eaf3a8f531999db140c2040f10016042b9d.tar.xz 42-cub3d-4f154eaf3a8f531999db140c2040f10016042b9d.tar.zst 42-cub3d-4f154eaf3a8f531999db140c2040f10016042b9d.zip |
Ram issues
Diffstat (limited to 'src/ft_get_fps_count.c')
-rw-r--r-- | src/ft_get_fps_count.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ft_get_fps_count.c b/src/ft_get_fps_count.c index 63bf08e..f7f0177 100644 --- a/src/ft_get_fps_count.c +++ b/src/ft_get_fps_count.c @@ -22,7 +22,6 @@ static float return ((ticks / (float)CLOCKS_PER_SEC) * 1000.0); } - static void ft_handle_firing(clock_t dt, t_cub *cl) { @@ -40,13 +39,16 @@ void ft_get_fps_count(clock_t dt, t_cub *cl) { static clock_t curr_time = 0; + static uint16_t ticks = 0; curr_time += dt; + ticks += 1; 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); + ft_sprintf(cl->fps_count, "fps: %hu", ticks); + ticks = 0; curr_time -= CLOCKS_PER_SEC; } } |