diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_time.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/ft_time.c b/src/ft_time.c new file mode 100644 index 0000000..2be702d --- /dev/null +++ b/src/ft_time.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_get_fps_count.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/17 20:06:26 by rbousset #+# #+# */ +/* Updated: 2020/02/17 20:06:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stddef.h> +#include <stdint.h> +#include <time.h> + +float + ft_clock_to_ms(clock_t ticks) +{ + return ((ticks * 1000.0) / (float)CLOCKS_PER_SEC); +} + +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) > 300.0) + { + cl->plist.fire = 0; + curr_time -= CLOCKS_PER_SEC; + } +} + |