/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_damage_bad_boy.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: joelecle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:22:32 by joelecle #+# #+# */ /* Updated: 2020/02/14 17:23:42 by joelecle ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include static uint8_t ft_get_bad_boy_id(t_cub *cl) { uint8_t i; i = 0; while (i < cl->mlist.sprite_nbr[13]) { if (llround(cl->sprites[13][i].s_pos_x) == (int64_t)cl->rlist.sqx && llround(cl->sprites[13][i].s_pos_y) == (int64_t)cl->rlist.sqy) break ; i++; } return (i); } void ft_damage_bad_boy(t_cub *cl) { uint8_t id; id = ft_get_bad_boy_id(cl); if (cl->plist.handles_weapon == 0) cl->bad_boy[id].life -= FT_W_ONE_DANAGE_AMOUNT; else if (cl->plist.handles_weapon == 2) cl->bad_boy[id].life -= FT_W_TWO_DANAGE_AMOUNT; else if (cl->plist.handles_weapon == 4) cl->bad_boy[id].life -= FT_W_THREE_DANAGE_AMOUNT; if (cl->bad_boy[id].isdead == 0 && cl->bad_boy[id].life <= 0) { cl->sfx[13].sfx_play(cl->sfx); cl->bad_boy[id].isdead = 1; cl->mlist.map[llround(cl->sprites[13][id].s_pos_y)] [llround(cl->sprites[13][id].s_pos_x)] = 'x'; } else if (cl->bad_boy[id].does != 3) cl->sfx[14].sfx_play(cl->sfx); }