/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_bad_boy_actions.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:28:51 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:28:51 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include #include void ft_bb_wait(t_bad_boy *bl, t_sprite *sl, t_map *ml) { (void)sl; (void)ml; bl->does = 0; } static void ft_bb_collision(double old_y, double old_x, t_sprite *sl, t_map *ml) { if (!ft_ischarset("0e", ml->map[lround(old_y)][lround(sl->s_pos_x)])) sl->s_pos_x = old_x; if (!ft_ischarset("0e", ml->map[lround(sl->s_pos_y)][lround(old_x)])) sl->s_pos_y = old_y; } void ft_bb_walk(t_bad_boy *bl, t_sprite *sl, t_map *ml) { int8_t r_x; int8_t r_y; const double old_x = sl->s_pos_x; const double old_y = sl->s_pos_y; if (FT_OS == 2) { r_x = random() % 3; r_y = random() % 3; } else { r_x = rand() % 3; r_y = rand() % 3; } r_x = (r_x == 2) ? (-1) : (r_x); r_y = (r_y == 2) ? (-1) : (r_y); sl->s_pos_x += (FT_MOVE_SPEED * 1.5 * r_x); sl->s_pos_y += (FT_MOVE_SPEED * 1.5 * r_y); ft_bb_collision(old_y, old_x, sl, ml); ml->map[lround(old_y)][lround(old_x)] = '0'; ml->map[lround(sl->s_pos_y)][lround(sl->s_pos_x)] = 'e'; bl->does = 1; } 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->bad_boy[i].sleep == 0) { 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++; } } void ft_bb_fire(t_bad_boy *bl, t_sprite *sl, t_map *ml) { (void)sl; (void)ml; bl->does = 2; }