aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_fps_count.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 19:04:46 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-19 19:04:46 +0100
commit6463914b0dc8136c453a1c163dd98f39e55e1c21 (patch)
tree0df94a05e92460e578da7092fde5b2502c8cceef /src/ft_get_fps_count.c
parentIt's going well (diff)
download42-cub3d-6463914b0dc8136c453a1c163dd98f39e55e1c21.tar.gz
42-cub3d-6463914b0dc8136c453a1c163dd98f39e55e1c21.tar.bz2
42-cub3d-6463914b0dc8136c453a1c163dd98f39e55e1c21.tar.xz
42-cub3d-6463914b0dc8136c453a1c163dd98f39e55e1c21.tar.zst
42-cub3d-6463914b0dc8136c453a1c163dd98f39e55e1c21.zip
Decent tier
Diffstat (limited to 'src/ft_get_fps_count.c')
-rw-r--r--src/ft_get_fps_count.c16
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);