diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 13:54:11 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-30 13:54:11 +0200 |
commit | a6dbe3b5710f719b3f02ba0044a72c64ee4155ac (patch) | |
tree | c1f64e3cfec00bd5b20d9f624370644fc8e62ef4 /src | |
parent | Better sword (diff) | |
download | 42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.gz 42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.bz2 42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.xz 42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.zst 42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.zip |
Bug fix
Diffstat (limited to '')
-rw-r--r-- | src/ft_get_fps_count.c | 21 | ||||
-rw-r--r-- | src/ft_shoot.c | 6 | ||||
-rw-r--r-- | src/ft_time.c | 37 |
3 files changed, 41 insertions, 23 deletions
diff --git a/src/ft_get_fps_count.c b/src/ft_get_fps_count.c index f7f0177..1f717e8 100644 --- a/src/ft_get_fps_count.c +++ b/src/ft_get_fps_count.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_key_loop.c :+: :+: :+: */ +/* ft_get_fps_count.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ @@ -16,25 +16,6 @@ #include <stdint.h> #include <time.h> -static float - ft_clock_to_ms(clock_t ticks) -{ - return ((ticks / (float)CLOCKS_PER_SEC) * 1000.0); -} - -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) > 300.0) - { - cl->plist.fire = 0; - curr_time -= CLOCKS_PER_SEC; - } -} - void ft_get_fps_count(clock_t dt, t_cub *cl) { diff --git a/src/ft_shoot.c b/src/ft_shoot.c index 09061b8..7f23bfd 100644 --- a/src/ft_shoot.c +++ b/src/ft_shoot.c @@ -49,9 +49,9 @@ static int8_t { if (cl->plist.handles_weapon == 0 && sqrtf(powf(cl->plist.pos_x - cl->rlist.sqy, 2) - + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) < 1.5) - return (1); - return (0); + + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) > 1.7) + return (0); + return (1); } static void 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; + } +} + |