/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_key_loop.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/17 20:06:26 by rbousset #+# #+# */ /* Updated: 2020/02/17 20:06:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include #include static void ft_check_bad_boy_shoot(t_cub *cl) { int8_t i; i = 0; while (i < cl->mlist.sprite_nbr[13]) { if (cl->bad_boy[i].does == 2) { cl->sfx[11].sfx_play(cl->sfx); if (FT_OS == 1) ft_macos_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); else ft_linux_suffer_animation(FT_ENMY_DAMAGE_AMOUNT, cl); } i++; } } int ft_key_loop(t_cub *cl) { uint8_t i; const float old_y = cl->plist.pos_y; const float old_x = cl->plist.pos_x; clock_t begin_frame; i = 0; while (i < 5 && cl->key_input[i] != -1 && cl->key_input[i] <= 5) { ft_handle_keys(i, old_y, old_x, cl); i++; } ft_check_bad_boy_shoot(cl); cl->moves = (cl->key_input[0] == -1) ? (0) : (cl->moves); begin_frame = clock(); ft_draw_scene(cl); ft_timings(begin_frame, cl); return (0); }