aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_time.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_time.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ft_time.c b/src/ft_time.c
index 2be702d..fb0b0d2 100644
--- a/src/ft_time.c
+++ b/src/ft_time.c
@@ -19,19 +19,28 @@
float
ft_clock_to_ms(clock_t ticks)
{
- return ((ticks * 1000.0) / (float)CLOCKS_PER_SEC);
+ return (ticks * 1000.0 / (float)CLOCKS_PER_SEC);
}
void
- ft_handle_firing(clock_t dt, t_cub *cl)
+ ft_handle_firing(clock_t before, t_cub *cl)
{
- static clock_t curr_time = 0;
+ static clock_t dt = 0;
+ clock_t curr;
- curr_time += dt;
- if (dt > 0 && ft_clock_to_ms(curr_time) > 300.0)
+ curr = clock();
+ dt += curr - before;
+ if (dt > 0 && ft_clock_to_ms(dt) > 700.0)
{
cl->plist.fire = 0;
- curr_time -= CLOCKS_PER_SEC;
+ dt = 0;
}
}
+void
+ ft_timings(clock_t before, t_cub *cl)
+{
+ if (cl->plist.fire == 1)
+ ft_handle_firing(before, cl);
+ ft_get_fps_count(before, cl);
+}