diff options
Diffstat (limited to 'src/ft_key_loop.c')
-rw-r--r-- | src/ft_key_loop.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c index c16655e..0108202 100644 --- a/src/ft_key_loop.c +++ b/src/ft_key_loop.c @@ -13,8 +13,9 @@ #include <libft.h> #include <cub3d.h> #include <mlx.h> -#include <stdint.h> #include <stddef.h> +#include <stdint.h> +#include <time.h> static uint64_t ft_find_x(int32_t key, const t_player *pl) @@ -77,25 +78,31 @@ int uint8_t i; const float old_y = cl->plist.pos_y; const float old_x = cl->plist.pos_x; + clock_t begin_frame; + begin_frame = clock(); i = 0; while (i < 5 && cl->key_input[i] != -1 && cl->key_input[i] <= 5) { cl->key_ptr[cl->key_input[i]](cl); - ft_collision(old_y, old_x, cl->key_input[i], cl); - if (cl->mlist.isnlvl) + if (cl->key_input[i] >= 0 && cl->key_input[i] <= 3) { - if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && - (uint32_t)cl->plist.pos_y == cl->mlist.nly) + ft_sfx_footstep(cl); + ft_collision(old_y, old_x, cl->key_input[i], cl); + if (cl->mlist.isnlvl) { - ft_sfx_new_level(cl); - return ((ft_warp_level(cl->mlist.nlevel_path, cl) < 0) ? - (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0)); + if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx && + (uint32_t)cl->plist.pos_y == cl->mlist.nly) + { + ft_sfx_new_level(cl); + return ((ft_warp_level(cl->mlist.nlevel_path, cl) < 0) ? + (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0)); + } } } i++; } - if (cl->key_input[0] != -1) - ft_draw_scene(cl); + ft_draw_scene(cl); + ft_get_fps_count(clock() - begin_frame, cl); return (0); } |